Magento 2 Fatal error: Call to a member function getAttributeText() on string

Magento 2 Fatal error: Call to a member function getAttributeText() on string

致命错误:在字符串 in/opt/lampp/htdocs/magento2_new/Sourcecode/app/design/frontend/Emthemes/em0150jewelry/jewelry/Magento_Catalog/templates/product/list.phtml 上调用成员函数 getAttributeText() 在行 539.This 上发生错误使用函数 $optionText=$_product->getId()->getAttributeText('Farben'); 我如何在 magento 2 中解决这个问题?

我不知道你为什么要获取 ID,我不太确定,但我认为以下代码可以工作:

$optionText=$_product->getAttributeText('Farben');

如果不评论