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

Magento2 Magento 2:如何在list.phtml上获取多个选择属性作为列表,magento2,Magento2,我已经为我的产品添加了一个multiple-select属性,现在我正试图在“list.phtml”模板上显示结果。(产品清单) 我得到的所有值如下: $attribute = $_product->getResource()->getAttribute('attribute_name')->getFrontend()->getValue($_product); 这将返回一个包含所有值的字符串,但我需要它是一个数组,这样我就可以将它转换为包含单个链接的列表 有什么帮助吗

我已经为我的产品添加了一个multiple-select属性,现在我正试图在“list.phtml”模板上显示结果。(产品清单)

我得到的所有值如下:

$attribute = $_product->getResource()->getAttribute('attribute_name')->getFrontend()->getValue($_product);
这将返回一个包含所有值的字符串,但我需要它是一个数组,这样我就可以将它转换为包含单个链接的列表

有什么帮助吗


谢谢

将对象转换为数组

$data=数组($attribute)

$data=(数组)$attribute

最终使用了:

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

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

感谢Jitendra,我最终使用了$data=explode(“,”,$string);如何以编程方式设置值?但是如果值中已经有逗号怎么办?在这种情况下,将单个值拆分为两个数组项是不正确的。