如何在 Magento 的 view.phtml 中显示标签产品 [英] How to display tags product in view.phtml of Magento
本文介绍了如何在 Magento 的 view.phtml 中显示标签产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了新主题并将它们用于创建产品.在查看页面中,我没有看到产品标签.我默认查看 view.pthml 并知道 "echo $this->getChildHtml('product_additional_data') "
中的标签,我的 view.phtml 也有,但为什么它不显示标签
I created new theme and use them for creating product. In view page, I don't see product tags. I review view.pthml in default and know that the tags in "echo $this->getChildHtml('product_additional_data') "
, my view.phtml has it too but why it don't display tags
请给个建议
推荐答案
这是我研究了大约 4 个小时后所做的.
This is what I did after about 4 hours of research.
<?php
// instantiate the tags class for products
$_tags = new Mage_Tag_Block_Product_List();
?>
<ul class="product-tags">
<?php foreach($_tags->getTags() as $tag):?>
<li><a href="<?=$tag->getTaggedProductsUrl()?>"><?=$tag->getName()?></a></li>
<?php endforeach;?>
</ul>
我不喜欢实例化类,所以如果我找到更优雅的方式,我会更新我的帖子.但至少它是一个 php 唯一的解决方案.
I don't like having to instantiate the class, so if I find a more elegant way I'll update my post. But at least it a php only solution.
这篇关于如何在 Magento 的 view.phtml 中显示标签产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文