steve_c Posted December 31, 2010 Share Posted December 31, 2010 Hi all...Is there any way I can hide a category on the left if there are no products available for it?Many thanks in advance,Stephen. Link to comment Share on other sites More sharing options...
rocky Posted December 31, 2010 Share Posted December 31, 2010 My AJAX Sliding Categories module has that option. That may be overkill if you don't want any of the other features in the module though.You could try changing the query on lines 267-273 of classes/Category.php (in PrestaShop v1.3.5) from: $result = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category` WHERE `id_lang` = '.intval($id_lang).' '.($active ? 'AND `active` = 1' : '').' ORDER BY `name` ASC'); to: $result = Db::getInstance()->ExecuteS(' SELECT * FROM `'._DB_PREFIX_.'category` c LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON c.`id_category` = cl.`id_category` WHERE `id_lang` = '.intval($id_lang).' '.($active ? 'AND `active` = 1' : '').' AND c.`id_category` IN (SELECT `id_category` FROM `'._DB_PREFIX_.'category_product`) ORDER BY `name` ASC'); Link to comment Share on other sites More sharing options...
steve_c Posted January 4, 2011 Author Share Posted January 4, 2011 Hi thanks for the reply - I've tried that but it didn't work.Website is www.malfordoflondon.com (for example - accessories > pocket squares > drakes is empty).Thanks,Stephen. Link to comment Share on other sites More sharing options...
gold refining Posted January 4, 2011 Share Posted January 4, 2011 I don't understand this problem ? Link to comment Share on other sites More sharing options...
steve_c Posted January 4, 2011 Author Share Posted January 4, 2011 ^^ It's quite simple - I just want to hide categories which are empty. All of my Drakes pocket squares have sold out so I don't want the category visible in the menu on the left. It's frustrating for customers.Stephen. Link to comment Share on other sites More sharing options...
steve_c Posted January 6, 2011 Author Share Posted January 6, 2011 Can anyone shed any light on this?Thanks Link to comment Share on other sites More sharing options...
rocky Posted January 7, 2011 Share Posted January 7, 2011 Perhaps it would be easier to just buy my AJAX Sliding Categories module. It keeps track of the number of products in each category, which it uses to provide the option to hide empty categories. Link to comment Share on other sites More sharing options...
Rohit Singhal Posted February 9, 2013 Share Posted February 9, 2013 Check out my module to hide empty categories in the sidebar and footer Non-empty Categories Module v1.0 Link to comment Share on other sites More sharing options...
La Cafeine Posted February 24, 2016 Share Posted February 24, 2016 (edited) hi rocky, when I use your code, that is work perfect, but the code hide also parent Caterory, so how to hide only the last children aterogy only pls ? I need choe the correct level_depth number ? how to add it in the SQL query Best Regerads. La Cafeine. Edited February 24, 2016 by La Cafeine (see edit history) 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