Showing posts with label magento product filter. Show all posts
Showing posts with label magento product filter. Show all posts

December 17, 2014

Magento Product Collection by Attribute Filter

Add attribute to filter in product collection


The below part code shows the product collection filter by attribute.

For example
You want to filter the product collection by status enabled product,
refer the code below this do that
$collection  = Mage::getModel ('catalog/product')
                    ->getCollection()
                    ->addAttributeToFilter('status',
                        array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
                      );

print_r($collection);