<?php
$myColorArr = myGetAttributeOptionArr('my_color');
echo '<pre>' . print_r($myColorArr, TRUE) . '</pre>';
function myGetAttributeOptionArr($attributeCode) {
$outArr = array();
$optArr = Mage::getSingleton('eav/config')->getAttribute('catalog_product', $attributeCode)->getSource()->getAllOptions();
foreach ($optArr as $val) {
if (empty($val['value']) || empty($val['label'])) {
continue;
}
$outArr[$val['value']] = $val['label'];
}
return $outArr;
}
?>
Sunday, February 8, 2015
Get attribute options values and lables by attribute code
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment