Skip to content

Magento: Get Attribute Options by Attribute Code

long time no post, this is useful script to get option list of product attribute

$attribute = Mage::getSingleton(‘eav/config’)->getAttribute(‘catalog_product’, ‘brand’);
if ($attribute->usesSource()) {
$options = $attribute->getSource()->getAllOptions(false);
foreach($options as $option) {

$data_array[$option[‘value’]]=$option[‘label’];
}
}

 

print_r($data_array)

/* result

Array
(
[value] => 81
[label] => Alergon
)
Array
(
[value] => 80
[label] => Hilo
)
Array
(
[value] => 79
[label] => L-Men
)
Array
(
[value] => 78
[label] => NutrIsari
)
Array
(
[value] => 77
[label] => Tropicana Slim
)
Array
(
[value] => 76
[label] => W’dank
)
Array
(
[value] => 75
[label] => WRP
)

*/

Share

Be First to Comment

Leave a Reply

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