I am writing a block which subclasses Mage_Catalog_Block_Layer_Filter_Category
to display a list of products in each category. To do this I apply addCategoryFilter()
to the layer product collection for each layer filter item, first using clear()
to remove any other filters. So I end up with $this->getLayer()->getProductCollection()->clear()->addCategoryFilter($category)
for each item.
The problem is the last-displayed category filter is not being cleared before the rest of the page renders. So the sidebar layered navigation is still filtered by it. How can I clear it?? I have tried doing $this->getLayer()->getProductCollection->clear()
in _afterToHtml()
but with no luck. Any help much appreciated.
Best Answer
The problem is getLayer is a singleton and holds afaik one collection. There is no easy way to achieve what you want. You can unset the whole collection (maybe) after doing whatever you are doing (which I didnt understand)