What are the rules that govern which entity “wins” in the case of conflicting URL paths

magento.stackexchange https://magento.stackexchange.com/questions/4620

سؤال

If multiple entities (e.g. a category, a product, a CMS page and a module frontname) all attempt to use the same SEF URL, what is the algorithm or process that Magento uses to decide which will be saved in core_url_rewrite with the desired request_path, and which will have suffixes appended to resolve the conflict (e.g. 'sale-123.html').

To ask the question another way, if a CMS page and category both ask for 'sale' as their URL, which will win?

هل كانت مفيدة؟

المحلول

Alan Storm wrote a long blog article about it: http://alanstorm.com/magento_dispatch_rewrites_intro

And to shorten it a little bit, it is all around penalty (?)

// Go through all found records and choose one with lowest penalty - earlier path in array, concrete store
    $mapPenalty = array_flip(array_values($path)); // we got mapping array(path => index), lower index - better
    $currentPenalty = null;
    $foundItem = null;
    foreach ($items as $item) {
        $penalty = $mapPenalty[$item['request_path']] << 1 + ($item['store_id'] ? 0 : 1);
        if (!$foundItem || $currentPenalty > $penalty) {
            $foundItem = $item;
            $currentPenalty = $penalty;
            if (!$currentPenalty) {
                break; // Found best matching item with zero penalty, no reason to continue
            }
        }
    }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top