【问题标题】:Displaying the value of a specific attribute for a certain product in magento shows error在 magento 中显示特定产品的特定属性值显示错误
【发布时间】:2012-04-25 07:26:04
【问题描述】:

我正在尝试显示某些产品的特定属性的值,但输出显示为“否”。这两种方法我都试过了,但都没有运气。

$color=($product->getResource()->getAttribute('color')->getFrontend()->getValue($product)); $shipping= $product->getAttributeText('package_id');

我不知道如何克服这个问题。我不知道我是否必须更改配置设置,因为我得到的输出只是说“否”。请帮我解决这个问题。

【问题讨论】:

    标签: php attributes magento-1.5


    【解决方案1】:

    如果你想获取属性前端值,那么试试这个

    nl2br($_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product)) 
    

    希望这会对你有所帮助。

    【讨论】:

    • 嗨 mufaddal,它仍然为值显示“否”。我为此苦苦挣扎?你有什么别的想法吗?
    • 嗨 mufaddal,我忘了清除缓存,您的解决方案效果很好。我可以在产品页面 view.phtml 中完成此操作,但我无法在购物车 sidebar.phtml 中完成此操作您知道我如何才能做到吗?
    • 如果您正确加载 prodcut 对象,您可以在任何地方使用此代码,如果您在购物车页面中加载产品,则此代码适合您
    • 嗨,你是对的,我没有正确加载产品。现在它很酷。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 2018-10-02
    • 1970-01-01
    • 1970-01-01
    • 2014-06-30
    相关资源
    最近更新 更多