Search code examples
magento2

Magento 2: How to get multiple selection attibute as list on list.phtml


I've added a multiple select attribute to my products an now I'm trying to show the result on "list.phtml" template. (Product list).

Im getting all the values like this:

$attribute = $_product->getResource()->getAttribute('attribute_name')->getFrontend()->getValue($_product);

This returns a String with all the values, but I need it to be an array so I can transform it to a list with individual links.

Any help?

thanks!


Solution

  • Ended up using:

    $attribute_string = $_product->getResource()->getAttribute('attribute')->getFrontend()->getValue($_product);
    
    $attribute_array = explode(', ', $attribute_string);