Monday, August 27, 2012

Magento : Get all options of a dropdown or multiselect attribute

Magento : Get all options of a dropdown or multiselect attribute

$arg_attribute = "manufacturer";//this may be any attribute code

//Object of attribute model

$attribute_model = Mage::getModel('eav/entity_attribute');

//Object of attribute options model

$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table') ;

//

$attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);

$attribute = $attribute_model->load($attribute_code);

$attribute_table =$attribute_options_model->setAttribute($attribute);

//Getting all options

$options = $attribute_options_model->getAllOptions(false);

//Printing all options of particular attribute

echo "<pre />";

print_r($options);

2 comments:

  1. Magento, a characteristic feature of the meet the needs of online marketers today. All assets business processes and dynamics of flow control is an on-line platform.Magneto's flexibility and scalability allows users to modify existing features or add new functionalities.

    http://www.indianic.com/magento-ecommerce-development.html

    ReplyDelete

  2. This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.
    magento development company in bangalore 

    ReplyDelete