I am trying to add additional filters to a collection after the collection seems to of been generated. In catalogue product list.phtml there is the following line of code:

$_productCollection = $this->getLoadedProductCollection();

When I var_dump this it does report back as a collection (Mage_Catalog_Model_Resource_Product_Collection). However if I try to add:

$_productCollection->addAttributeToFilter('attr_handle', array('eq' => 155));

directly after the first line, the resulting collection is still exactly the same. How can I modify what is in $_productCollection in list.phtml?

Any help is appreciated

---- UPDATE ----

I notice that in the List.php block the collection is loaded in the _beforeToHtml method:


I am assuming therefore I have to "unload" (?) it and then apply my filters in the view and then re-load it (?)

3 Answers 3


You can call $collection->clear(), apply your filters, and then reload the collection. However IIRC the collection will be in a different state than the layer model expects.

This a combination of both Mage_Catalog_Model_Resource_Product_Collection::clear() and Varien_Data_Collection::clear().

  • Seems to work for what I am trying to do. Fantastic! Thanks.
    – beingalex
    Sep 16, 2013 at 15:08

You can filter product collection before loading. See following, your config.xml


And Observer.php:

class SSD_Ajaxify_Model_Observer
public function catalogProductCollectionLoadBefore($observer)
            $request = Mage::app()->getRequest();
            $path    = implode('_', array(
            if ($path == 'catalog_category_view') {
                $collection = $observer->getEvent()->getCollection();
                $collection->addAttributeToFilter('price', array('gt'=> 50));

By the way this affects to your toolbar and layered navigation, and also product list in category view page.

  • 1
    $path = Mage::app()->getFrontController()->getAction()->getFullActionName() might be a bit cleaner.
    – benmarks
    Sep 16, 2013 at 15:47

By using rewrite Magento Product List Block, we can add an extra filter in product collection.

Please use below link for reference:-

Hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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