分層導航使用單獨加載的集合對象。
一種可能的方式,以確保未來的導航過濾器正確的計數是覆蓋模型Mage_Catalog_Model_Layer
和你的過濾器添加到其功能Mage_Catalog_Model_Layer::prepareProductCollection
public function prepareProductCollection($collection)
{
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addMinimalPrice()
->addFinalPrice()
->addTaxPercents()
->addUrlRewrite($this->getCurrentCategory()->getId())
->addAttributeToFilter('type_id', 'simple');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
return $this;
}
要做到這一點你當地代碼庫創建一個模塊。在3210文件中添加以下節點到節點global
<models>
<catalog>
<rewrite>
<layer>YourPackage_YourModule_Model_Rewrite_Layer</layer>
</rewrite>
</catalog>
</models>
在你的模塊添加目錄「重寫」文件夾下的「樣板」,並在其上創建文件Layer.php
。在創建的文件Model/Rewrite/Layer.php
添加一個類,定義如下:
class YourPackage_YourModule_Model_Rewrite_Layer extends Mage_Catalog_Model_Layer {
}
添加功能上面這個類,清除緩存。
爲什麼這些產品在這個類別中,如果你不想讓他們在那裏開始? – clockworkgeek
因爲當用戶在產品頁面(可配置)時,我需要完整的麪包屑(主頁>分類>子菜單>產品) 使用顏色色板模塊。我想在類別頁面中顯示所有簡單的產品,並且當用戶點擊某個產品時,他會轉到該簡單產品的可配置產品,使用完整面包屑 – Paulo