Magento - 产品页面上的Echo属性

a1a*_*anm 7 magento

在我的Magento商店中,我创建了一个属性代码为'brand_info'的新属性.

如何将此属性的内容回显/打印到产品页面上,即.在描述下面?

小智 11

要在产品页面上显示属性的内容,您需要在view.phtml文件中添加以下代码.

$_product->getResource()->getAttribute('brand_info')->getFrontend()->getValue($_product);
Run Code Online (Sandbox Code Playgroud)


Jos*_*tey 7

确保该属性标记为"在前端使用",然后在模板名称中写下以下要查看属性的位置:

<?php print $_product->getBrandInfo(); ?>
Run Code Online (Sandbox Code Playgroud)


小智 5

将以下代码添加到您的catalog/product/view.phtmlcatalog/product/list.html模板文件中:

echo $_product->getAttributeText('your_attribute_code');
Run Code Online (Sandbox Code Playgroud)

只需更改your_attribute_code属性代码就可以了.