Just another WordPress.com weblog

Posts tagged ‘attribute’

Get Attribute options and values

// Add the attribute code here.
$attribute=$product->getResource()->getAttribute("color");
// Checking if the attribute is either select or multiselect type.
if($attribute->usesSource()){
// Getting all the sources (options)
$options = $attribute->getSource()->getAllOptions(false);
}
// print as label-value pair
echo '<pre>'. print_r($options) .'</pre>';

Thanks,
– Bijal Bhavsar 🙂

Advertisements