I have created a custom attribute (color_materials) in Magento admin, which input type is set to dropdown. I'm trying to get this attribute value programatically, and I have the following code.

$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getSku($_item));
$productOption = $product->getData('color_materials');

The output i got is a number, which is stored in catalog_product_entity_int. But I want to get it's associated text, not a number. How can I achieve this?

3 Answers 3


use getAttributeText

 $product = Mage::getModel('catalog/product')->loadByAttribute('sku',$this->getSku($_item));
 $productOption = $product->getAttributeText('color_materials');
  • Thanks. It worked. Can you also tell me where to get a full list of Magento functions? it was simply because I didn't know there's a function called getAttributeText(). Commented Mar 22, 2017 at 7:36
  • @Zhenyu the function is located app/code/core/Mage/Catalog/Model/Product.php on line 1381 function getAttributeText Commented Mar 22, 2017 at 7:39

Since your attribute type is dropdown $product->getData('color_materials'); will return you the value.

Since you need the label you can use


Other ways

$id = $this->getProduct()->getId();
$_resource = Mage::getSingleton('catalog/product')->getResource();
$optionValue = $_resource->getAttributeRawValue($id,  'color_materials', Mage::app()->getStore());
echo $optionValue;



Return the attribute option Id , in case of dropdown or multiselect.

For fetching attribute option text you have to write below code


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.