3

I have this code to get values from select/multiselect attributes

<?php
$attributes = $_product->getAttributes();
$themeColor = $attributes['theme_color']->getFrontend()->getValue($_product);
echo $themeColor;
?>

But it works only for select. When I'm pointing it to multiselect attribute it show nothing.

  • Try this: $attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product); – pzirkind Jun 22 '14 at 17:00
1

To be more descriptive,

$_product = $this->getProduct();
$_product -> getThemeColor(); //this will return the attribute values separated by comma
$_product -> getAttributeText('theme_color'); //this will return the labels of the options separated by comma.
0

Try with

$_product->getAttributeText('theme_color');
  • No - it isn't working – Marek Badura Feb 24 '14 at 13:48
0

You should be able to get the value(s) of the multiselect attribute for a given product by using the following code:

$attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product);

If however you want to get all possible options for a given mutli-select attribute use this code:

$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','attribute_code_here');

$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);

$attributeOptions = $attribute ->getSource()->getAllOptions();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.