halalan Posted August 21, 2009 Share Posted August 21, 2009 I find at times I may have a visible category that currently has NO products. I don't want a customer to click on a category that is empty...(it makes them get bored and leave the site). But, I don't want to always have to go into the backend and uncheck that category to make it invisible.Soooooo....is there a easy way to either show next to the Category Name a product count?Example:CATEGORIESShirts (0)Pants (3)Shoes (6)Atleast this way a person would know not to bother clicking on a Category if its EMPTY?? It doesn't need to show inventory amounts..just if products exhist in that category and if so how many..... Link to comment Share on other sites More sharing options...
rocky Posted August 22, 2009 Share Posted August 22, 2009 Good idea. I've added this to my categories block module as an optional feature. I've been busy lately, but I hope to finish it soon. I had to add a new SQL query to the block to get the number of products in each category, then I modified the getTree() function to display the number of products in brackets after each category. Link to comment Share on other sites More sharing options...
CYTechnologies Posted August 22, 2009 Share Posted August 22, 2009 Hello,Here's what you can do, this will require a little bit of modding * store - the folder that is housing your prestashop installation.* please backup your files before making any changes, just in case.1. Open the file store/modules/blockcategories/blockcategories.php 2. go to line 118-119 and find $$row['name'] = Category::hideCategoryPosition($row['name']); $resultParents[$row['id_parent']][] = $row; $resultIds[$row['id_category']] = $row; 3. copy the below code and paste above the code found on step 2. // exclude home category if($row['id_category'] != 1) { $result_product_count = Db::getInstance()->ExecuteS(' SELECT COUNT(`id_product`) as totalProducts FROM `'._DB_PREFIX_.'category_product` WHERE `id_category` = '.$row['id_category']); $row['product_count'] = $result_product_count[0]['totalProducts']; } 4. Now, go back up in the script to line 85-86 and find the code 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); 5. copy the below code and replace the code found in step 4. (notice the new product_count at the end of the array) 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']); 6. Save the file and upload it to your server.7. Open the file store/modules/blockcategories/category-tree-branch.tpl 8. Find the code below (it should be the second line down) {$node.name|escape:htmlall:'UTF-8'} 9. Add the below code to the end of step 8. ({$node.product_count}) It should look like this: {$node.name|escape:htmlall:'UTF-8'} ({$node.product_count}) That should do it, if I missed a step or something doesn't work right, just post back here You can see it in action on my store (I should say up and coming store haha)http://cytech-services.com/store/I hope this helps! 1 Link to comment Share on other sites More sharing options...
halalan Posted August 22, 2009 Author Share Posted August 22, 2009 That's exactly what I am talking about! However, I just switched over to a new Block Categories Module (blockcategoriesaccordian v1.6 ) I like the the mouse over effect to open for subcategories, but still want that extra info to display. Not sure how close the code is.....to try the mode. But since its ROCKY from the post two up...maybe its my lucky day !!!!! :-)Plus...I try not to modify to much..its a pain when upgrading to newer level of prestashop.. I always find I forget stuff :-)Appreciate the input the storefront I am working on is http://www.ozarkclassiccraftsmall.com Link to comment Share on other sites More sharing options...
CYTechnologies Posted August 22, 2009 Share Posted August 22, 2009 Hey Halalan,You should still be able to do the changes in blockcategories.php - I'm assuming the accordion update was mainly for the template and not the actual source files. Make sure you back up all files that you are going to edit and try it out. If it doesn't work, simply post back here and we will figure something out Just to note - when adding the actual count to the .tpl file, the important part is ({$node.product_count}), use that to place the count where you want, it should still work with the new module. Link to comment Share on other sites More sharing options...
halalan Posted August 22, 2009 Author Share Posted August 22, 2009 I appreciate the info... It's something that I feel is a must for any website with lots of categories..you don't want a person to get bored on your site with empty product categories.I still need to figure out why the new block category is still showing a little of the --- category1 those --- are hiding behind the first letters of each category(IT's BROWSER RELATED) damn Explorer8 .. Like you said its probably in the template file - but just switched to the new block last night !! Link to comment Share on other sites More sharing options...
CYTechnologies Posted August 22, 2009 Share Posted August 22, 2009 Whats the link to your store? Link to comment Share on other sites More sharing options...
halalan Posted August 22, 2009 Author Share Posted August 22, 2009 The link to my current project site is http://www.ozarkclassiccraftsmall.com the issue is only showing up using Explorer8 if I run it in compatibility mode the dashes showing up..go away. I usually work in IE8 because most folks use it...I know techies use Firefox..but I try to use what is normal for the average John Doe !! :-)UPDATE NOTE: That weird issue I just figured out is a THEME only issue...it doesn't show the - - under the first letters in the category block when I switch over to the standard prestashop theme in either browswer setting, So...I got my homework cut out for me.. Link to comment Share on other sites More sharing options...
nitindb Posted August 23, 2009 Share Posted August 23, 2009 I tried what cytechnologies suggested but but found that my categories block went completely blank, showing no categories at all. I'm viewing with FireFox 3.5.2. Link to comment Share on other sites More sharing options...
CYTechnologies Posted August 23, 2009 Share Posted August 23, 2009 Hello,Double check to make sure you didn't miss a step or remove something that wasn't supposed to be removed, also could you give me a link to your website so I can see it?To all those who want to use this modification you can download it here:http://www.cytech-services.com/store/product.php?id_product=14I also updated the script so it takes into effect active products.Please keep in mind I'm still working on the store aspect so don't be afraid if you see some weird things haha Link to comment Share on other sites More sharing options...
Robin1 Posted August 24, 2009 Share Posted August 24, 2009 Nice article.Its drastically breathtaking expound owing to me.Hope this cede limn deserved appurtenant to every one.Thanks whereas sharing this overpowering one.Keep posting.All the elite whereas your budgeted posts. Link to comment Share on other sites More sharing options...
nitindb Posted August 24, 2009 Share Posted August 24, 2009 The store is being created on my private server at the moment. Just playing around before I start serving it on the web. I'll go through you're instructions again and see if I've missed something. Link to comment Share on other sites More sharing options...
SmartiesKiller Posted September 4, 2009 Share Posted September 4, 2009 For which version did that work ?i try on 1.2.2 ands don't show the numer between () Link to comment Share on other sites More sharing options...
migash Posted September 13, 2009 Share Posted September 13, 2009 Great solution. Confirmed that it also works with the horizontal categories module. PS 1.2.2 Link to comment Share on other sites More sharing options...
nitindb Posted September 18, 2009 Share Posted September 18, 2009 Tried it again and worked without any issues. Wonderful! Link to comment Share on other sites More sharing options...
ysco Posted September 23, 2009 Share Posted September 23, 2009 Nice addon But i have a question,Is it possible to make it work with blockslidingcategories ?? I use that one i have looked at the code but it completely different.Would love to have this working on this module, wel no one dead for asking so i thought i give it a shot Greats, ysco.. Link to comment Share on other sites More sharing options...
rocky Posted September 24, 2009 Share Posted September 24, 2009 Hi ysco,I've already added this option to v2.0 of my sliding categories module, but I'm reluctant to release it since there are a few obvious bugs in it. I want to get the module perfect before I release it. Unfortunately, I've been busy working on websites for various clients, which I've found to be much easier to make a living on than writing Prestashop modules. When I get a break between websites, I'll work on finishing this module.Rocky Link to comment Share on other sites More sharing options...
ysco Posted September 24, 2009 Share Posted September 24, 2009 Hello rockey,Thats great news mate, i understand dat works goes before the hobby.So we proberly must wait a bit longer but thats no problem, is it not possible to add the code myself to my catogerieslider that i use now from you?Thanks in advance,Greats, Ysco.. Link to comment Share on other sites More sharing options...
aquamarine Posted January 10, 2010 Share Posted January 10, 2010 @CYTechnologiesI will like to do it only for subcategories. How would you do it for that? I only have 1 category section with many subcategories.Thank you! Link to comment Share on other sites More sharing options...
AFemaleProdigy Posted March 11, 2012 Share Posted March 11, 2012 Can anyone help me get this working in the latest version of Prestashop? When I follow those steps, it makes my site load a blank white page. I have started my own new thread as well asking for help, but no one is responding. I would appreciate some help with this. Thanks! Link to comment Share on other sites More sharing options...
joseluismartisanmiguel Posted January 2, 2013 Share Posted January 2, 2013 Working on 1.5.2! 1 Link to comment Share on other sites More sharing options...
sztamas04 Posted March 18, 2013 Share Posted March 18, 2013 (edited) Works fine on 1.5.3.1! Edited March 18, 2013 by sztamas04 (see edit history) Link to comment Share on other sites More sharing options...
stuartvideo Posted March 25, 2013 Share Posted March 25, 2013 Can anyone help me get this working in the 1.4.8.2 version of Prestashop? steps not working.? StuartVideo.com Link to comment Share on other sites More sharing options...
Recommended Posts