Magento – How do I get the ID for an attribute option?

Here is my current code which gives me the options of my attribute:

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', '158');
foreach ( $attribute->getSource()->getAllOptions(false) as $option){
//$attributeArray[$option['value']] = $option['label'];
echo"<li><a href="".Mage::getURL()."catalogsearch/advanced/result/?nf_featires[]=".$option['label']."">".$option['label']."</li>";


I am trying to link them up but I need the option ID in order to have the search page return results. How do I pull the option ID?

3 thoughts on “Magento – How do I get the ID for an attribute option?”

  1. Your answer didn’t work Jonathan. What did work was $option['value'] and it required me changing getAllOptions(false) to getAllOptions(true)

Leave a Reply

Your email address will not be published. Required fields are marked *