8 February 2011 0 Comments

[Magento] Get Products by an attribute

I need to search all products by a product attribute in Magento. Magento provides a loadByAttribute function which gives all products match the passed attribute. You just need to pass attribute name and its value in the function. You can see the below example to get more idea.

$products = Mage::getModel(‘catalog/product’)->loadByAttribute(‘attribute_name’, $attribute_value);

      
Tweet
    Freelance PHP Developer