Load product by attribute in magento
Posted by navaneeth on Jan 23, 2014 in Magento | No comments yet

While generally we load a product in Magento by its id, it is also possible to load product by attribute in magento. To do that use the following code –
$product = Mage::getModel('catalog/product')->loadByAttribute('attribute_name', $attribute_value);
Just replace ‘attribute_name’ with the name of the attribute and $attribute_valuewith the value and then Magento will return the matching products.
Leave a Reply