Prestashop: Add tags to the product list

Source: http://nemops.com/prestashop-product-list-tags/#.XPt5M7hS-Ul

1) Product.php class (use override)

Insert code at the last part of public static function getProductProperties($id_lang, $row, Context $context = null)
/* add product tags to product list */
$row['tags'] = array();
$tags = Tag::getProductTags($row['id_product']); //show product tags in listing
if($tags && isset($tags[$context->language->id])) //show product tags in listing
$row['tags'] = $tags[$context->language->id]; //show product tags in listing

2) product-list.tpl (in theme folder)
<div class="product-tags">{if $product.tags}{foreach from=$product.tags item=tag}<a class="btn bth-default" href="{$product.link|escape:'html':'UTF-8'}" title="{$tag|escape:'html':'UTF-8'}" >{$tag}</a>{/foreach}{/if}</div>

3) global.js (in theme folder) add this above the product-reference html in 3 views (grid, table, list) it looks for product-tags name in div so make sure that matches in product-list.tpl
html += '<div class="product-tags">'+$(element).find('.product-tags').html()+'</div>';

Note: no all products have tags, so may mess up the listing layout. Add a min-height to the product-container to e.g. 500px

This entry was posted in templates and tagged , . Bookmark the permalink.