Questions around the TYPO3 integration and plugins as well as Flow and NeosCMS
Forum rules: Always add your TYPO3/Flow, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#1922 by aimeos
18 Sep 2015, 17:32
trimble wrote:I think, it would be great to have the option to show categories only in the frontend if they associated with an enabled product.


In which scenario categories should be hidden?

1.) If a category contains no products at all
It's possible but requires executing a least one additional query and a filtering of the category nodes afterwards. This is quite expensive and what is if child categories have products associated? If you have a category with no products associated, you can easily disable it in the admin interface or during a product import.

2.) If a category doesn't contain any products matching the current filter
The product counts for the categories are calculated asynchronous way to prevent a slow down of rendering the filter and the other elements of the page. Thus, you can only hide categories via Javascript after the page is loaded which might be confusing for the user if categories are vanishing after the page is loaded.
#1923 by trimble
18 Sep 2015, 18:10
This is the scenario I'm thinking of.
1.) If a category contains no products at all
It's possible but requires executing a least one additional query and a filtering of the category nodes afterwards. This is quite expensive and what is if child categories have products associated? If you have a category with no products associated, you can easily disable it in the admin interface or during a product import.


A Category should only be hidden if it has no child categories with associated products.

I know that's easy to disable a category in the admin interface but it's although easy to forget to disable a category when a product with a unique category is sold out.
#1924 by aimeos
19 Sep 2015, 10:12
trimble wrote:A Category should only be hidden if it has no child categories with associated products.


In that case, the whole category subtree would have to be checked if there are any products associated to one of the categories.

trimble wrote:I know that's easy to disable a category in the admin interface but it's although easy to forget to disable a category when a product with a unique category is sold out.


That's a different scenario because sold out products are still associated to a category and are displayed to the customer. The stock level of a product is determined in an asynchronous way too.
#1926 by trimble
19 Sep 2015, 13:13
That's a different scenario because sold out products are still associated to a category and are displayed to the customer. The stock level of a product is determined in an asynchronous way too.


You're right. I forgot to write that I build a shop which will have unique products always with a few amount and when the product is sold out it will be removed and 'never' comes back. So it's a nice feature to have removed the associated category automatically when no other product ist associated with the category too.
#1932 by aimeos
22 Sep 2015, 08:36
trimble wrote:I forgot to write that I build a shop which will have unique products always with a few amount and when the product is sold out it will be removed and 'never' comes back. So it's a nice feature to have removed the associated category automatically when no other product ist associated with the category too.


OK, this is a very special case. You can do this with Aimeos when you add a filter that removes all categories without products and stocks before they are handed over to the template for rendering but you have to implement that yourself or pay somebody if you are not a developer.