evolution.x Posted February 6, 2012 Share Posted February 6, 2012 Hi All, As the title says, could anybody help with displaying product count on subacatergories. Please see pictures. Thanks in advance! Link to comment Share on other sites More sharing options...
cedricfontaine Posted February 6, 2012 Share Posted February 6, 2012 Well, if I had to do it, I will probably override classes/Category.php. I would add a subcategory count directly in function getSubCategories(); On line 483, after $row['legend'] = 'no picture'; I would add the following $categ = new Category((int)$row['id_category'], (int)$id_lang); $row['nbproducts'] =$categ->getProducts(NULL, NULL, NULL, NULL, NULL, true); I didn't test it Link to comment Share on other sites More sharing options...
evolution.x Posted February 6, 2012 Author Share Posted February 6, 2012 Well, if I had to do it, I will probably override classes/Category.php. I would add a subcategory count directly in function getSubCategories(); On line 483, after $row['legend'] = 'no picture'; I would add the following $categ = new Category((int)$row['id_category'], (int)$id_lang); $row['nbproducts'] =$categ->getProducts(NULL, NULL, NULL, NULL, NULL, true); I didn't test it Hi, Thanks for your response. I am running PS v1.3.2.3 and my code is as follows in classes/catergory.php: /* Modify SQL result */ foreach ($result AS &$row) { $row['name'] = Category::hideCategoryPosition($row['name']); $row['id_image'] = (file_exists(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg')) ? intval($row['id_category']) : Language::getIsoById($cookie->id_lang).'-default'; $row['legend'] = 'no picture'; } return $result; } private static function getAllSubCats(&$all_cats, $id_cat, $id_lang) { $category = new Category(intval($id_cat)); $sub_cats = $category->getSubcategories($id_lang); if(count($sub_cats) > 0) foreach ($sub_cats AS $sub_cat) { $all_cats[] = $sub_cat['id_category']; self::getAllSubCats($all_cats, $sub_cat['id_category'], $id_lang); } } Where would i insert your code and how do i call it in catergory.tpl? Cheers Link to comment Share on other sites More sharing options...
cedricfontaine Posted February 6, 2012 Share Posted February 6, 2012 Add it just after $row['legend'] = 'no picture'; In your tpl, you can use $subcategory.nbproducts Link to comment Share on other sites More sharing options...
evolution.x Posted February 6, 2012 Author Share Posted February 6, 2012 Great! Your code works fine, just one request / question. I have catergories set up like this: Home > Bulbs (0) > Single End (0) > BLV (10) Home > Bulbs (0) > Double End (0) > BLV (5) On the bulbs cat it shows 0 products as they are within child subcats, is it possible to show like this: Home > Bulbs (15) > Single End (10) > BLV (10) Home > Bulbs (15) > Double End (5) > BLV (5) Thanks for your help! Link to comment Share on other sites More sharing options...
evolution.x Posted February 8, 2012 Author Share Posted February 8, 2012 Anybody have any ideas on the above? Cheers Link to comment Share on other sites More sharing options...
cedricfontaine Posted February 8, 2012 Share Posted February 8, 2012 What is the URL I can see it ? Link to comment Share on other sites More sharing options...
evolution.x Posted February 8, 2012 Author Share Posted February 8, 2012 Hi, URL: http://www.bioaquatek.com/57-lighting The code works but does not count products inside a subcatergory which is already in a subcatergory. Link to comment Share on other sites More sharing options...
evolution.x Posted February 9, 2012 Author Share Posted February 9, 2012 I have turned your mod off for now as it may be confusing for customers when they see 0 Products on high level subcatergories. If you need to look please post in here and i will turn the mod back on. Your help is very much appreciated. Link to comment Share on other sites More sharing options...
cedricfontaine Posted February 10, 2012 Share Posted February 10, 2012 Well, I might have to work on it longer in order to find a solution. For now, I have no time to do it for free. It's really specific to your needs. You'd have to do a recursive count of subcategories... Link to comment Share on other sites More sharing options...
evolution.x Posted February 10, 2012 Author Share Posted February 10, 2012 Ok, how much would you charge for the modification? Link to comment Share on other sites More sharing options...
cedricfontaine Posted February 13, 2012 Share Posted February 13, 2012 You have a MP ! Link to comment Share on other sites More sharing options...
evolution.x Posted February 13, 2012 Author Share Posted February 13, 2012 Thank you for all your help and advise but i have solved my problem. Once again thank you. Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted March 11, 2012 Share Posted March 11, 2012 Thank you for all your help and advise but i have solved my problem. Once again thank you. Hi, what was your solution to this? I am trying to do the same thing and can't get anyone to answer me in these forums. Link to comment Share on other sites More sharing options...
evolution.x Posted March 12, 2012 Author Share Posted March 12, 2012 Hi, what was your solution to this? I am trying to do the same thing and can't get anyone to answer me in these forums. Hi, I purchased this module: http://www.nethercottconstructions.com/en/prestashop-modules/1-ajax-sliding-categories.html 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