[英]Show Attribute Value in list.phtml
I try to show an attribute value for each product on the product list.我尝试在产品列表中显示每个产品的属性值。 I tried this one:
我试过这个:
<?php echo $_product->getResource()->getAttribute('myAttribute')->getFrontend()->getValue($_product); ?>
It works fine in view.phtml but shows nothing in list.phtml.它在 view.phtml 中工作正常,但在 list.phtml 中没有显示。 What am I doing wrong?
我究竟做错了什么?
let's say you have created a enquire attribute.假设您已经创建了一个查询属性。 Then just load product with sku.
然后只需加载带有 sku 的产品。
$_sku = 'some_value';
$product = Mage::getModel('catalog/product')->loadByAttribute('sku',$_sku);
then simple use this to get value.然后简单地使用它来获取价值。
$product->getEnquire();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.