レイヤードナビゲーションブロックをカスタムページに追加します

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

  •  16-10-2019
  •  | 
  •  

質問

Magentoでは、階層化されたナビゲーションブロックは、製品リストページでうまく機能します。

このブロックは、製品のカスタムリストがあるカスタムページにどのように正常にコピーできますか?

注:XMLにブロックを追加して、それを呼び出すだけです getChildHtml('blockname') トリックをしません。

役に立ちましたか?

解決

基本的にあなたがしなければならないことはです extend/overwrite から mage_catalog_block_product_list (List.php) 書き換えます getProductCollection() 方法:

protected function _getProductCollection()
{
    if (is_null($this->_productCollection)) {
        // Build collection and set it
        $collection = "...";
        $this->setProductCollection($collection);
    }

    return $this->_productCollection;
}

それが終わったとき、私は両方を上書きしました Mage_Catalog_Model_Layer クラスと Mage_Catalog_Model_Category 新しい変数を導入しました。

protected $_customProductCollection;

上書きしました getProductCollection() 両方のクラスで、私はこれをメソッドの冒頭に追加しました。

if(isset($this->_customProductCollection)){
    return $this->_customProductCollection;
}

また、これを設定できる方法もあります "customProductCollection" これらの両方のクラス内。それが設定されると、残りのデータは 層状ナビゲーション/カテゴリ このコレクションに基づいています。

最初の質問+回答をチェックしてください ここ.

幸運を ;)

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top