Magento: Get Product Attribute

During Magento Development, You may face such situation in which you need to access product attributes.

This attribute can be Manufacturer of product or Model of product or any attribute which you were created using Magento Back end.

So at several places you may want to access the value or id of those attributes. So how you can get value or id of that attribute? Let us see.

To get any attribute value or id for any product, first of all you need instance of that that product.

Suppose you want attribute of product which id is 10. Then see following code to load values of that product.

{code type=php}
$_product = Mage::getModel(‘catalog/product’)->load(10);

Above code load product which has id 10.

Now suppose you want to access value of manufacturer of this product, then consider following code.
{code type=php}
$manufacturerValue = $_product->getAttributeText(‘manufacturer’);
And if you want to access id of manufacturer then use following code.
{code type=php}
$manufacturerId = $_product->getManufecturer();

Similarly you can get any attribute value and id using this method, just replace manufacturer with appropriate attribute name.

That’s all.

Magento Get Product Attribute, Magento Get Product Manufacturere, Magento get Product Model, Magento Development

Comment are closed.