簡體   English   中英

如何在list.phtml中獲得自定義的Magento屬性?

[英]How can I get custom Magento attributes in list.phtml?

如何在Magento(版本1.4)產品類別列表(在list.phtml )中獲得自定義屬性?

我正在嘗試通過添加來編輯catalog.xml

<action method="addAttribute"><code>format</code></action>

並在list.phtml

<?php echo $_product->getAttributeText('format'); ?>

要么

<?php echo $_product->getFormat(); ?>

但這是行不通的。 如何才能做到這一點?

它工作正常,只需將此代碼放在list.phtml或view.phtml文件中所需的位置即可。

$attribute = $_product->getResource()->getAttribute('unit');
if ($attribute){
    echo $attribute_value = $attribute ->getFrontend()->getValue($_product);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM