CYTechnologies 4 Posted August 24, 2009 Hey all,Module: Category Navigation - Product CountVersion: 0.1Tested On: 1.2.1Cost: FreeThis modification allows you to show the number of active products on your category navigation.Example: Software (150)To learn more, see it in action, and to download it please go to:http://www.cytech-services.com/store/product.php?id_product=14Hope this will be handy for a few people :-) 1 Share this post Link to post Share on other sites
halalan 0 Posted August 24, 2009 Excellent....thanks for the work Share this post Link to post Share on other sites
SmartiesKiller 3 Posted September 8, 2009 i try but nothing appear between ()any help ?? Share this post Link to post Share on other sites
CYTechnologies 4 Posted September 8, 2009 Hey,Where you able to complete the first round of changes? the php code part? Also, what did you put between the ()? Share this post Link to post Share on other sites
ysco 77 Posted September 8, 2009 Thanks for sharing this nice module, will try it out.ysco.,. Share this post Link to post Share on other sites
SmartiesKiller 3 Posted September 8, 2009 hi CYTechnologiesi do exactly what your put in your install.html file but nothing appear you can see it on my site www.lecoindesfemmes.frSorry for bad english that not my first language. Share this post Link to post Share on other sites
golojap 0 Posted October 1, 2009 Working just fine on PS 1.2.3 (I still have to update :-S). Thanks a lot !! Share this post Link to post Share on other sites
geiri 0 Posted October 9, 2009 This is a nice mod but it does not count products in subcategories and does not show products in sub categories when they are expanded. Share this post Link to post Share on other sites
maxlink 0 Posted October 13, 2009 thanks man. will try it out !.. this's mod i'm looking for. Share this post Link to post Share on other sites
Ratatosk 2 Posted November 26, 2009 Works fine, thank you !!!.How to make it works for the subcategories please ? Share this post Link to post Share on other sites
aquamarine 0 Posted January 31, 2010 what about subcategories? I can't find anywhere in the forums about the count for subcategories. Thanks Share this post Link to post Share on other sites
rocky 953 Posted February 1, 2010 My category block here has the option to include subcategories in the product count and has many more features. Share this post Link to post Share on other sites
eGzyl.pl 2 Posted January 23, 2011 its ok, but i try do somethink like that:category (11) [only one products is there] - where that number is all products from subcat + all product from categorysupcat (4)subcat (6)some body done it? Share this post Link to post Share on other sites
cycleelcyc 3 Posted January 29, 2011 I just try to install this module, it looks cool but after i return back to my old blockcategories.php and category-tree-branch.tpl, on the catagory tree, it always appear the "()", anyone know how can i remove it? Share this post Link to post Share on other sites
patate34 0 Posted February 22, 2011 Open the file ../modules/blockcategories/category-tree-branch.tpl Find the below code {$node.name|escape:htmlall:'UTF-8'} ({$node.product_count}) Replace by this code {$node.name|escape:htmlall:'UTF-8'}{if $node.product_count > 0}({$node.product_count}) {/if} Best regards. Share this post Link to post Share on other sites
cycleelcyc 3 Posted March 13, 2011 Open the file ../modules/blockcategories/category-tree-branch.tpl Find the below code {$node.name|escape:htmlall:'UTF-8'} ({$node.product_count}) Replace by this code {$node.name|escape:htmlall:'UTF-8'}{if $node.product_count > 0}({$node.product_count}) {/if} Best regards. it works, thank you Share this post Link to post Share on other sites
adhd_kid 9 Posted April 19, 2011 also, if you want the number of products to appear only from the level 2 categories downwards (not on the 'main screen') , just replace the mentioned code for the category-branch-tree.tpl file to: category-branch-tree.tpl {if $node.bazinga_depth neq 1}{if $node.product_count > 0}({$node.product_count}){/if}{/if} and add this line: 'bazinga_depth'=>$currentDepth to your blockcategories.php file so it looks like this around 85 line: blockcategories.php return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => Category::hideCategoryPosition($resultIds[$id_category]['name']), 'desc'=> $resultIds[$id_category]['description'], 'children' => $children, 'product_count' => $resultIds[$id_category]['product_count'],'bazinga_depth'=>$currentDepth); Share this post Link to post Share on other sites
anylamar 0 Posted May 6, 2011 I wonder how they are related products can not see where I configure this option ... Please I'm urgently ... Thanks Share this post Link to post Share on other sites
DesignMonstr 1 Posted June 10, 2011 also, if you want the number of products to appear only from the level 2 categories downwards (not on the 'main screen') , just replace the mentioned code for the category-branch-tree.tpl file to:category-branch-tree.tpl {if $node.bazinga_depth neq 1}{if $node.product_count > 0}({$node.product_count}){/if}{/if} and add this line: 'bazinga_depth'=>$currentDepth to your blockcategories.php file so it looks like this around 85 line: blockcategories.php return array('id' => $id_category, 'link' => $link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']), 'name' => Category::hideCategoryPosition($resultIds[$id_category]['name']), 'desc'=> $resultIds[$id_category]['description'], 'children' => $children, 'product_count' => $resultIds[$id_category]['product_count'],'bazinga_depth'=>$currentDepth); Thanks a million for posting this. Share this post Link to post Share on other sites
rocky 953 Posted July 4, 2011 My AJAX Sliding Categories module has code that counts all products in subcategories. It modifies the getTree() function to count the products in each category and uses recursion to include subcategory counts in parent categories. It then caches the product numbers in the database for fast retrieval. Unfortunately, it's complicated code that I can't simply write here. Share this post Link to post Share on other sites
DylzEn 1 Posted July 25, 2012 (edited) I would also like some code to count all products in any particular tree, all the way down, as a single sum, as jakubek noted: - top cat (Candy Bars) has one product - sub cat has four products - sub-sub cat has six products So, the final display for top cat looks like this: Candy Bars (11) Has anyone ever devised this type of summation code? I'm looking for the exact same thing, has anyone found a solution to this and is willing to post it here? We'd appreciate it. Edited July 25, 2012 by DylzEn (see edit history) Share this post Link to post Share on other sites
martialdelastic 3 Posted February 15, 2016 For add the count of product in subcategory you can do this (it's work in prestashop 1.6.0.9) : 1 : Create file who name category.php in overrhide/classes repertory who contain => <?php /* this overhide is for add the products_nbr variable who have the count of product active in sub cateory recucivly */ class Category extends CategoryCore { public function getSubCategories($id_lang, $active = true) { $sql_groups_where = ''; $sql_groups_join = ''; if (Group::isFeatureActive()) { $sql_groups_join = 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = c.`id_category`)'; $groups = FrontController::getCurrentCustomerGroups(); $sql_groups_where = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '='.(int)Group::getCurrent()->id); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.*, cl.id_lang, cl.name, cl.description, cl.link_rewrite, cl.meta_title, cl.meta_keywords, cl.meta_description FROM `'._DB_PREFIX_.'category` c '.Shop::addSqlAssociation('category', 'c').' LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (c.`id_category` = cl.`id_category` AND `id_lang` = '.(int)$id_lang.' '.Shop::addSqlRestrictionOnLang('cl').') '.$sql_groups_join.' WHERE `id_parent` = '.(int)$this->id.' '.($active ? 'AND `active` = 1' : '').' '.$sql_groups_where.' GROUP BY c.`id_category` ORDER BY `level_depth` ASC, category_shop.`position` ASC'); foreach ($result as &$row) { $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : Language::getIsoById($id_lang).'-default'; $row['legend'] = 'no picture'; $row['products_nbr'] = $this->getSubCatNbProductsRecursive($row['id_category'], $row['nleft'], $row['nright']); } return $result; } public function getSubCatNbProductsRecursive($id ,$nleft, $nright) { $nb_product_recursive = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT COUNT(distinct(id_product)) FROM `'._DB_PREFIX_.'category_product` WHERE id_category IN ( SELECT c2.id_category FROM `'._DB_PREFIX_.'category` c2 '.Shop::addSqlAssociation('category', 'c2').' WHERE c2.nleft > '.(int)$nleft.' AND c2.nright < '.(int)$nright.' AND c2.active = 1 UNION SELECT '.(int)$id.' ) AND id_product IN ( SELECT c3.id_product FROM `'._DB_PREFIX_.'product` c3 '.Shop::addSqlAssociation('product', 'c3').' WHERE c3.active = 1 UNION SELECT '.(int)$id.' ) '); if (!$nb_product_recursive) return 0; return $nb_product_recursive; } } 2 : add {if $subcategory.products_nbr > 1} <h6>{$subcategory.products_nbr} Products</h6>{/if} after <h5><a class="subcategory-name" href="{$link->getCategoryLink($subcategory.id_category, $subcategory.link_rewrite)|escape:'html':'UTF-8'}">{$subcategory.name|truncate:45:'...'|escape:'html':'UTF-8'|truncate:350}</a></h5> in the category.tpl of your theme directory. 3 : delete the file class_index.php in cache directory 4 : delete your cache smarty in the performance page in back office. Share this post Link to post Share on other sites
angelt 3 Posted February 4, 2017 Not work for 1.6.1.0 Share this post Link to post Share on other sites