How to hide all disabled products category, what is the best practice to achieve in Magento 2.3.4?
-
when you want to hide categories?– Rakesh DongaSep 24, 2020 at 9:03
-
@RakeshDonga We disabled random items, some of the categories have 0 products, but the category still visible and shown no products, how to hide the category if 0 products in it?– zusSep 24, 2020 at 9:13
-
I hope my point clear, how to achieve this shall i use observer or plugins?– zusSep 25, 2020 at 9:58
1 Answer
Where do you want to hide your category ?
If it's in the filter then it's the native magento behaviour to hide them when they have no products.
If it's not there, then you probably just need to override the template calling the category like in your menu, and use a count condition on the category items.
An other work around would bo to override the controller that call the category and if a category is called with no items you can do whatever you want. (Because even if you can't see the category it doesn't mean that your Jean Kevin user can't enter his path in the adress bar.
-
We disabled random items, some of the categories have 0 products, but the category still visible and shown no products, how to hide the category if 0 products in it?– zusSep 24, 2020 at 9:53
-