Wednesday, September 5, 2012

Magento get Attribute Options


>> Get all Options of an Attribute  : 

    $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_code');        // attribute code here
    $ingredientArr = array();
    foreach ( $attribute->getSource()->getAllOptions(true, true) as $option)
    {
        $ingredientArr[] = array(
            'value' => $option['value'],
            'label' => $option['label']
        );
    }

Note : $option['value'] is the id and $option['label'] is the option name.