z4m0lx3 0 Posted August 31, 2010 Hello,I'd like to be able to show the number of products next to each Category in the menu.For example:Accessories (24)Cosmetics (10)what do I have to do? ( Quote Share this post Link to post Share on other sites
rocky 925 Posted August 31, 2010 My AJAX Sliding Categories module has the option to display the number of products in each category (and optionally its subcategories too). It also lets you dynamically load categories to reduce the page loading time. Quote Share this post Link to post Share on other sites
z4m0lx3 0 Posted September 1, 2010 seems a big price for what I need it's indeed useful but I only need to show the number of products ( Quote Share this post Link to post Share on other sites
rocky 925 Posted September 2, 2010 In that case, try this module. Quote Share this post Link to post Share on other sites
alexidro 4 Posted March 5, 2012 Here is the solution tested and working in Prestashop 1.4.7. You can follow these instructions below or just download the already modified files from the zip file attached here. Hope this helps. Open "blockcategories.php" in the folder /modules/blockcategories and find this lines of code (should start at line 140 or so): public function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0) { global $link; $children = array(); if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (!isset($resultIds[$id_category])) return false; return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'], 'children' => $children); } And change them to this: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = 1, $currentDepth = 0) { global $link; $children = array(); if (isset($resultParents[$id_category]) AND sizeof($resultParents[$id_category]) AND ($maxDepth == 0 OR $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (!isset($resultIds[$id_category])) return false; $ProductsCount = 0; $ProductsCount = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'category_product WHERE id_category = '. $id_category); return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => $resultIds[$id_category]['name'], 'desc'=> $resultIds[$id_category]['description'], 'children' => $children, 'products' => $ProductsCount); } Then open the file "category_tree_branch.tpl" that you find in the same folder /modules/blockcategory and find this line (should be line 41): <a href="{$node.link}" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'}</a> and change to this: <a href="{$node.link}" {if isset($currentCategoryId) && ($node.id == $currentCategoryId)}class="selected"{/if} title="{$node.desc|escape:html:'UTF-8'}">{$node.name|escape:html:'UTF-8'} ({$node.products})</a> blockcategories_numbers_mod.zip 2 Quote Share this post Link to post Share on other sites
ammarshadiq 0 Posted April 19, 2013 (edited) To Clarify, the files that you should edited are located at themes/my_theme/modules/blockcategories/category-tree-branch.tpl clear the cache and the compile folder, and refresh the page. Hope this helps. Edited April 19, 2013 by ammarshadiq (see edit history) Quote Share this post Link to post Share on other sites
angelt 2 Posted February 4, 2017 (edited) Not work for 1.6.1.0 actually it works in 1.6.1.11 Edited February 6, 2017 by angelt (see edit history) Quote Share this post Link to post Share on other sites
ndiaga 273 Posted November 22 On 2/4/2017 at 3:00 PM, angelt said: Not work for 1.6.1.0 actually it works in 1.6.1.11 You can read this tutorial for the 1.7 version : https://blog.prestatuts.com/show-number-of-products-next-to-each-category-in-category-tree-menu/ Quote Share this post Link to post Share on other sites