2

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.

1

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)

-1

Try this before you taking the collection from layer

Mage::unregister('_singleton/catalog/layer');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.