1

I'm trying to display all possible values (dropdown options) of a product in Magento. I'm using the code bellow:

    <?php
  $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'display_size'); //"display_size" is my attribute_code
  $allOptions = $attribute->getSource()->getAllOptions(true, true);
  foreach ($allOptions as $instance) {
    $id = $instance['value'];
    $value = $instance['label'];
  }
?>

but the page doesn't display any results. Any idea?

Thanks, O.

0

You code give you all option of attribute ,not given an individual product option.

If yo want to get a specific product option and it value then try below

$productObject->getAttributeText('display_size'); 

It given the option label

for getting option id then try the below

$productObject->getData('display_size'); 
| improve this answer | |
  • above code doesn't display anything :( – user15151 May 18 '15 at 10:42

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