Just another WordPress.com weblog

// 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

Comments on: "Get Attribute options and values" (2)

  1. Anupama said:

    Hi Bijal..

    Its useful to me .. thanks .. keep writing

  2. This will get the option value and is much simpler:

    $_product->getAttributeText($attributeCode)

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

%d bloggers like this: