Struggling to get value of the selected option for product.

Example:Product require assembly so created attribute dropdown Below few methods I've tried

echo $data = $_product->getAssembly();
echo $label = $_product->getAttributeText('Assembly');

$_attribute = $_product->getResource()->getAttribute('assembly');
$attribute_label = $_attribute->getStoreLabel(Mage::app()->getStore()->getName());

echo 'Label: '.$attribute_label;//empty
$attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product','assembly');

echo 'Model: '.$attributeModel;// empty
$atributeCode = 'assembly';

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$atributeCode);
$options = $attribute->getSource()->getAllOptions();

var_dump is displaying only an array of all options.

How can I get it ?

  • SO this was right: echo $data = $_product->getAssembly(); echo $label = $_product->getAttributeText('Assembly'); the only problem was capital "A" :) Thank you
    – Rob D. A.
    Feb 20, 2017 at 14:04

1 Answer 1


$_product->getAssembly() should return you the id of the option selected for the current product.

$_product->getAttributeText('assembly') (notice the lowercase attribute name) should return you the label of the selected assembly option for the current product.

But there is a catch.
If you are trying these in the product list page or somewhere where the $_product is one iteration from a product collection you have to mark the assembly attribute as "Used in product listing" and rebuild your product flat indexes in order to work.


Your Answer

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

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