競合するURLパスの場合、どのエンティティが「勝つ」かを支配するルールは何ですか

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

質問

複数のエンティティ(カテゴリ、製品、CMSページ、モジュールのフロントネームなど)がすべて同じSEF URLを使用しようとする場合、Magentoが使用するアルゴリズムまたはプロセスは何ですか? core_url_rewrite 目的で request_path, 、そして、競合を解決するために追加される接尾辞( 'Sale-123.html'など)があります。

別の方法で質問をするために、CMSページとカテゴリが両方とも「販売」をURLとして求めている場合、勝つでしょうか?

役に立ちましたか?

解決

アラン・ストームはそれについて長いブログの記事を書きました:http://alanstorm.com/magento_dispatch_rewrites_intro

そして、それを少し短くするために、それはすべてペナルティの周りにあります(?)

// 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