如何在Magento的view.phtml中显示标签产品 [英] How to display tags product in view.phtml of Magento

查看:58
本文介绍了如何在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

plz,有什么建议

推荐答案

这是经过大约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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆