I'm working on a module where some products have an attribute named designer
. and for every designer
, all products by him displayed as catalog category view
. So far I'm able to filter the products collection by designer
attribute and successfully display them as the catalog category view
page.
But now the problem is, I need to display a layered navigation for those product which may be filtered by price and all.
Is there a way that I could add layered navigation in that filtered product collection?
Best Answer
Mohammad found an answer on StackOverflow which has since been deleted. Here is that answer:
Finally I found the solution for custom Layered navigation for custom product collection. Here are the changes what I have did to sort-out this issue.
1. Created one custom module for custom page. My custom page URL was http://{magento_root}/onsale
2. Set below Layout XML file for my custom page layout (
onsale
is my custom attribute)3. In
onsale/category/view.phtml
I have just set page title & called product listing$this->getChildHtml('product_list');
.4. Now I have three block file, a)
onsale
, b)product_list
, c)layer_view
.a)
Mymodule_Onsale_Block_Onsale
extendsMage_Core_Block_Template
and it has just two method one for_prepareLayout
& for_prepareLayout
.b)
Mymodule_Onsale_Block_Product_List
extendsMage_Catalog_Block_Product_List
and it has just one method which is as below:c)
layer_view
block has one methodgetLayer()
as below:5. No changes in controller, just call to Layout & Render.
6. Now for model file. I have just one model file for layer with
getProductCollection
method as below which extend toMage_Catalog_Model_Layer
.class name Mymodule_Onsale_Model_Layer extends Mage_Catalog_Model_Layer
7. One last important, Please set
No
toUse Flat Catalog Category
&Use Flat Catalog Product
atSystem -> configuration -> Catalog -> fontend
.It show me correct product listing with layered navigation.