0

This question already has an answer here:

I am using $_item->getData("attribute_code") to fetch the attribute code in the related products on the product page, but it does not seem to work with multiselect attributes. Is there a variation on the code that would accomplish this?

marked as duplicate by Jaimin Sutariya, Murtuza Zabuawala, Keyul Shah, Siarhey Uchukhlebau, 7ochem Mar 23 '17 at 12:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

For getting values from select or multi-select, you need to use below code,

echo $_item->getResource()->getAttribute('attribute_code')->getFrontend()->getValue($_item);

or

echo implode(", ",$_item->getAttributeText('attribute_code'));
  • Thanks, I used <?php echo $_item->getResource()->getAttribute('attribute_code')->getFrontend()->getValue($_item); ?> and it works for other attributes but not for multiselect. – Marcel Mar 22 '17 at 11:03
  • please check updated answer also make sure your attribute is visible on list page – Jaimin Sutariya Mar 22 '17 at 11:08
  • It is visible on the list page – Marcel Mar 22 '17 at 11:15
  • Are you using default related product block? I have checked the same code and found its working. Also please add your magento version to your question. – Jaimin Sutariya Mar 22 '17 at 11:38

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