Jump to content

Hide category if no products available?


Recommended Posts

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

  • 2 years later...
  • 3 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...