{"id":608,"date":"2019-06-08T09:54:16","date_gmt":"2019-06-08T09:54:16","guid":{"rendered":"http:\/\/angelwings.net\/blog\/?p=608"},"modified":"2019-06-08T09:54:16","modified_gmt":"2019-06-08T09:54:16","slug":"prestashop-add-tags-to-the-product-list","status":"publish","type":"post","link":"https:\/\/angelwings.net\/blog\/prestashop-add-tags-to-the-product-list\/","title":{"rendered":"Prestashop: Add tags to the product list"},"content":{"rendered":"<p>Source: http:\/\/nemops.com\/prestashop-product-list-tags\/#.XPt5M7hS-Ul<\/p>\n<p>1) Product.php class (use override)<\/p>\n<p>Insert code at the last part of public static function getProductProperties($id_lang, $row, Context $context = null)<br \/>\n<code>\/* add product tags to product list *\/<br \/>\n$row['tags'] = array();<br \/>\n$tags = Tag::getProductTags($row['id_product']); \/\/show product tags in listing<br \/>\nif($tags &amp;&amp; isset($tags[$context-&gt;language-&gt;id])) \/\/show product tags in listing<br \/>\n$row['tags'] = $tags[$context-&gt;language-&gt;id]; \/\/show product tags in listing<\/code><\/p>\n<p>2) product-list.tpl (in theme folder)<br \/>\n<code>&lt;div class=\"product-tags\"&gt;{if $product.tags}{foreach from=$product.tags item=tag}&lt;a class=\"btn bth-default\" href=\"{$product.link|escape:'html':'UTF-8'}\" title=\"{$tag|escape:'html':'UTF-8'}\" &gt;{$tag}&lt;\/a&gt;{\/foreach}{\/if}&lt;\/div&gt;<\/code><\/p>\n<p>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<br \/>\n<code>html += '&lt;div class=\"product-tags\"&gt;'+$(element).find('.product-tags').html()+'&lt;\/div&gt;';<\/code><\/p>\n<p>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<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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[&#8216;tags&#8217;] = array(); $tags = Tag::getProductTags($row[&#8216;id_product&#8217;]); \/\/show product tags in listing if($tags &amp;&amp; isset($tags[$context-&gt;language-&gt;id])) \/\/show product tags in listing $row[&#8216;tags&#8217;] = $tags[$context-&gt;language-&gt;id]; \/\/show product [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[103,105],"class_list":["post-608","post","type-post","status-publish","format-standard","hentry","category-templates","tag-prestashop","tag-prestashop-1-6"],"_links":{"self":[{"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/posts\/608","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/comments?post=608"}],"version-history":[{"count":0,"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/posts\/608\/revisions"}],"wp:attachment":[{"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/media?parent=608"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/categories?post=608"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/angelwings.net\/blog\/wp-json\/wp\/v2\/tags?post=608"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}