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

Your email address will not be published.