samydavic Posted August 28, 2011 Share Posted August 28, 2011 Hi, I offer a modificated Block Categories module that can show/hide number of items per category. Tested in Prestashop 1.4 Please see demo: http://store.ixtusarte.com.ar Available in: http://www.ingenex.com.ar Best regards! Link to comment Share on other sites More sharing options...
alexidro Posted March 5, 2012 Share 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 1 Link to comment Share on other sites More sharing options...
dhaiha Posted March 21, 2012 Share Posted March 21, 2012 Hi alexidro. I installed your script. Everything went fine but I always have to choose "Force compile = Yes" and "Cache = No" ( in the Preferences -> Performance Tab). Any other combination would make the category tree displayed without number showing. Do you have any idea ? Thx in advance. Link to comment Share on other sites More sharing options...
dhaiha Posted March 21, 2012 Share Posted March 21, 2012 I found out. Atfer deleting cached files on Smarty directory everything is OK. Link to comment Share on other sites More sharing options...
CONetWebDesign Posted May 16, 2012 Share Posted May 16, 2012 Hi alexidro - I downloaded your files (many thanks for those!) but it doesnt seem to show the number of products in each category unfortunately. See here: http://www.dev6.designbyconet.com/category.php?id_category=3 Any ideas? Link to comment Share on other sites More sharing options...
acdc Posted July 28, 2012 Share Posted July 28, 2012 (edited) Dont work on PrestaShop™ 1.4.8.2 Edited July 28, 2012 by acdc (see edit history) Link to comment Share on other sites More sharing options...
tank Posted August 3, 2013 Share Posted August 3, 2013 Thanks! It worked on my 1.4.9.0 shop Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now