Magento 2:如何在 list.phtml 上获取多个选定属性作为列表

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

我已经为我的产品添加了多个 select 属性,现在我正试图在 "list.phtml" 模板上显示结果。 (产品列表)。

我得到的所有值都是这样的:

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

这个 returns 一个包含所有值的字符串,但我需要它是一个数组,这样我就可以将它转换为包含单独链接的列表。

有什么帮助吗?

谢谢!

正在将对象转换为数组。

$data = array($attribute);

$数据=(数组)$属性;

最终使用:

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

$attribute_array = explode(', ', $attribute_string);