Magento(ver。1.8.0.0)のカスタムモジュールで、特定の製品の関連製品の一覧を表示しています。カスタム製品コレクションのMagentoレイヤードナビゲーション
これを達成するために、Mage_Catalog_Block_Product_List
クラスを上書きして自分のモジュールを作成しました。基本的にはここに
は、それがどのように動作するかです:
私は製品entity_id
をキャッチし、私は
list.phpと呼ばれている私のカスタム書かれたブロックの中でそれを使用することができますので、私はレジストリに製品を保管コントローラからここでは、製品のコレクションを埋める方法は次のとおりです。
protected function _getProductCollection()
{
if (is_null($this->_productCollection)) {
$prod = Mage::registry('chosenproduct');
$this->_productCollection = $prod->getRelatedProductCollection()
->addAttributeToSelect('required_options')
->addAttributeToFilter(array(array('attribute'=>'accessory_manufacturer','neq'=>false)))
->addAttributeToSort('position', 'asc')
->addStoreFilter()
->setPageSize(30)
->setCurPage(1);
;
$this->_addProductAttributesAndPrices($this->_productCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_productCollection);
$this->setProductCollection($this->_productCollection);
}
return $this->_productCollection;
}
私はまた、層状のナビゲーションが表示さを確認するために私のカスタムモジュールのレイアウトの.xmlに次のように追加しました:
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
階層的なナビゲーションが表示されますが、上記で追加した方法で使用されているカスタムコレクションではなく、すべての製品をコレクションと見なしているようです。
私も、私はこの$layer = Mage::getSingleton('catalog/layer');
を使用してカタログ/層を得ることができることを知っている層のクラスもprepareProductCollectionとsetCollectionというメソッドを持っていますが、何らかの理由で、私はそれを動作させることはできません。
これに関する助力?
基本的には、カスタムコレクションに含まれる製品のレイヤードナビゲーションが必要です。
ありがとう、
この設定方法とは何ですか、どこから呼び出すのですか? – easymoden00b