Muntashir Are Rahi Muntashir Are Rahi - 3 months ago 12
PHP Question

Show Tag on each products in product list in home or category page in prestashop

I want to print tag on each product thumbnail in the product list of my prestashop store. I tried adding the following code in product-list.tpl

<span class="tptag btn btn-danger">
{foreach from=Tag::getProductTags($product.id_product) key=k item=v}
{foreach from=$v item=value}
<a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a>
{/foreach}
{/foreach}
</span>


But it fetching nothing. How can i display the tags.?

Answer

Try this:

<span class="tptag btn btn-danger">
    {foreach Tag::getProductTags($product.id_product) as $k=>$tags}
        {foreach $tags as $tag}
            <a href="{$link->getPageLink('search', true, NULL, [tag =>$tag|urlencode])}">{$tag|escape:html:'UTF-8'}</a>
        {/foreach}
    {/foreach}
</span>
Comments