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

  $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.


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


It given the option label

for getting option id then try the below

| 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.