1

I am using echo $_product->getAttributeText('target') in /app/design/frontend/default/mytheme/template/catalog/product/list.phtml to show the Input Type "Multiple Select".

The product is a "Simple product" with multiple selections in the Attribute "target".

But, result shows "Array" whenever there are more than one selection.

Would there be any good solution to this issue ?

2
  • what is you want???are you want to show in left panel of list page
    – Amit Bera
    Aug 11, 2014 at 18:22
  • I want to show the text of the assigned attributes just below the short description and "Read more", in list.phtml. If there are more than one value assigned, it should show like Color: "Blue, Red, Yellow"... or Size: "Small, XXL, XXXL" Aug 12, 2014 at 19:18

1 Answer 1

1

getAttributeText for multiselects actually returns an array of all the text values selected. It's a slight misnomer based on the method name but you can still work with it by looping through it like an array:

$targetValues = $_product->getAttributeText('target');
foreach($targetValues as $_target) ...

Since it's a simple array and not a Magento collection object, you could also implode it if you just wanted to render them out with a simple comma separation or something similar.

1
  • I tried this again with no luck. Log is showing "Notice: Array to string conversion" and "Notice: Undefined offset: 0", and all I see in frontend is "Array". May 4, 2019 at 21:15

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.