I have an all.phtml page that I listed all products in here.

This code can get all products info but I want to list by attribute (like search)

$_helper = $this->helper('catalog/output');
$fancybox = MAGE::helper('ThemeOptions')->getThemeOptions('fancybox' );
$grid = MAGE::helper('ThemeOptions')->getThemeOptions('grid' );

How can I do that?

  • What do you mean? Do you want all products filtered by size? I don't understand the question Commented Feb 21, 2014 at 15:13
  • There are 2 attributes for products. I want filtered by (for example) color and size or just color or just size. Commented Feb 21, 2014 at 15:15

1 Answer 1


The logic inside of the Mage_Catalog_Block_Product_List is very complex and depends on a lot of classes, e.g. the layer for layered navigation.

$this->getLoadedProductCollection() says it already, the collection is loaded, therefore it is not possible to add filters.

I think the easiest way is to hook into catalog_block_product_list_collection check whether the action is the one, you want to change (this event is thrown at various places) and then just add the filters with

$collection->addAttributeToFilter($attributeName, $value)

The alternative is to extend the list class and implement the method _beforeToHtml so you can do whatever you want. Then you have to change the block class in your layout.xml

  • After researched I found this is possible. Used this and worked very well. $_productCollection->clear()->addAttributeToFilter('room', '6')->load(); Commented Feb 21, 2014 at 15:45

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.