Magento – Get all the velues of EAV attribute from attribute code

Tech Bandhu

Many time we do required to get the all values of attribute or lets sey all option values of EAV attribue, while code a custom module or functionality. Bellow code would help you get all option values of EAV attribue,

// get the list of all gender type
public function getGenderList()
{
      $genders = array();
      $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'gender'); // "gender" is attribute_code
      $allOptions = $attribute->getSource()->getAllOptions(true, true);
      foreach ($allOptions as $instance) {
           $genders[$instance['value']] = $instance['label'];
      }
      return $genders;
}

above function will returns array of gender type, gender is attribute of catalog_product.

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s