Magento : list all values of an attribute

You want to see all values of an attribute, for debug purpose or something else ?

$attr_model = Mage::getModel('catalog/resource_eav_attribute');
$attr_model->load(959); // you can find the attribute_id on the eav_attribute table
$options = $attr_model->getSource()->getAllOptions(false);
foreach($options as $value)
{
     print_r($value);
     echo "<br />";
}

You will get something like that :

Array
(
    [value] => 154
    [label] => 2008
)
Array
(
    [value] => 155
    [label] => 2009
)
Array
(
    [value] => 156
    [label] => 2010
)

Leave a Reply