Content Module Product Number
- natselection
-
Topic Author
- Offline
Less
More
7 years 10 months ago #299710
by natselection
Content Module Product Number was created by natselection
-- HikaShop version -- : 3.5.1
-- Joomla version -- : 3.8.13
-- PHP version -- : 7.2
-- Browser(s) name and version -- : All
We're using the content module to display a grid of categories. In the module settings we have Product number set to Yes to show the number of products in each category. It appears that it counts each product and each variant. Is it possible to exclude variants from being counted?
-- Joomla version -- : 3.8.13
-- PHP version -- : 7.2
-- Browser(s) name and version -- : All
We're using the content module to display a grid of categories. In the module settings we have Product number set to Yes to show the number of products in each category. It appears that it counts each product and each variant. Is it possible to exclude variants from being counted?
Please Log in or Create an account to join the conversation.
7 years 10 months ago #299732
by nicolas
Replied by nicolas on topic Content Module Product Number
Hi,
The count is done based on the link between the elements in the hikashop_product_category table.
Through the interface of HikaShop, it's normally impossible to add entries in that table for variants (since variants don't have a "categories" setting).
However, if there was some custom plugin, or maybe some weird mass action, or maybe some wrongly configured CSV import, it might be possible to have such entry in the hikashop_product_category table, which would explain why variants are counted.
But again, normally, it shouldn't happen.
Could you check the entries in that table through your phpmyadmin ?
The count is done based on the link between the elements in the hikashop_product_category table.
Through the interface of HikaShop, it's normally impossible to add entries in that table for variants (since variants don't have a "categories" setting).
However, if there was some custom plugin, or maybe some weird mass action, or maybe some wrongly configured CSV import, it might be possible to have such entry in the hikashop_product_category table, which would explain why variants are counted.
But again, normally, it shouldn't happen.
Could you check the entries in that table through your phpmyadmin ?
Please Log in or Create an account to join the conversation.
- natselection
-
Topic Author
- Offline
7 years 10 months ago - 7 years 10 months ago #299755
by natselection
Replied by natselection on topic Content Module Product Number
Ok, I did some digging and here's what I found...
It's counting incorrectly for a few categories, not all. For example:
Current counts show
Vehicles lifts (90)
Shop Equipment (6)
Other (65)
Actual count should be:
Vehicles lifts (30)
Shop Equipment (3)
Other (31)
If I look at the category "Shop Equipment" which has a category_id of 13:
topsecretequipment.com/
There are only 3 products in that category:
topsecretequipment.com/categories/vehicl.../13-k-shop-equipment
If I query the hikashop_product_category table to see what's in there for category_id=13 it only returns the three products:
So somewhere it's not counting properly and I can't find anything obvious that could be the cause.
It's counting incorrectly for a few categories, not all. For example:
Current counts show
Vehicles lifts (90)
Shop Equipment (6)
Other (65)
Actual count should be:
Vehicles lifts (30)
Shop Equipment (3)
Other (31)
If I look at the category "Shop Equipment" which has a category_id of 13:
topsecretequipment.com/
There are only 3 products in that category:
topsecretequipment.com/categories/vehicl.../13-k-shop-equipment
If I query the hikashop_product_category table to see what's in there for category_id=13 it only returns the three products:
So somewhere it's not counting properly and I can't find anything obvious that could be the cause.
Last edit: 7 years 10 months ago by natselection. Reason: Fixed image
Please Log in or Create an account to join the conversation.
7 years 10 months ago #299765
by nicolas
Replied by nicolas on topic Content Module Product Number
Hi,
Could it be that these 3 products are in several categories ? Do these products have variants ?
Could it be that these 3 products are in several categories ? Do these products have variants ?
Please Log in or Create an account to join the conversation.
- natselection
-
Topic Author
- Offline
7 years 10 months ago #299782
by natselection
Replied by natselection on topic Content Module Product Number
Yes, they are in multiple categories.
For example the Shop Equipment category that is showing 6, all of those are in nested categories:
Shop Equipment
-Frame Benches (2)
-Rotisseries (1)
They also all have 2 variants.
I just tried removing a category from one and the count decreased by one. So it is indeed caused by being in multiple categories that are nested. I would think they they really only should be counted once, no matter the category assignments. We have some menu items that show the parent category list of products, as well as a few that show just a subcategory list of products so removing the parent category woulnd't be optimal.
For example the Shop Equipment category that is showing 6, all of those are in nested categories:
Shop Equipment
-Frame Benches (2)
-Rotisseries (1)
They also all have 2 variants.
I just tried removing a category from one and the count decreased by one. So it is indeed caused by being in multiple categories that are nested. I would think they they really only should be counted once, no matter the category assignments. We have some menu items that show the parent category list of products, as well as a few that show just a subcategory list of products so removing the parent category woulnd't be optimal.
Please Log in or Create an account to join the conversation.
7 years 10 months ago #299787
by nicolas
Replied by nicolas on topic Content Module Product Number
Hi,
Normally, in such case, you would change the "sub element filter" setting to "all sub elements" under the "products options" tab of the menu item showing the parent cartegory list of products.
That way, even without the product in the parent category, it would still display the product in that parent menu while counting it only once.
The goal of counting the product once per category is that suppose that you have categories like that:
main cat 1
- sub cat 1
- sub cat 2
main cat 2
And that you have one product which is in both sub cat 1 and sub cat 2.
When you are on the listing of main cat 1 and and main cat 2, you want to display the count "2" because when you open that category, you want to have the count "1" for both sub cat 1 and sub cat 2.
I hope you can see what I mean.
Normally, in such case, you would change the "sub element filter" setting to "all sub elements" under the "products options" tab of the menu item showing the parent cartegory list of products.
That way, even without the product in the parent category, it would still display the product in that parent menu while counting it only once.
The goal of counting the product once per category is that suppose that you have categories like that:
main cat 1
- sub cat 1
- sub cat 2
main cat 2
And that you have one product which is in both sub cat 1 and sub cat 2.
When you are on the listing of main cat 1 and and main cat 2, you want to display the count "2" because when you open that category, you want to have the count "1" for both sub cat 1 and sub cat 2.
I hope you can see what I mean.
Please Log in or Create an account to join the conversation.
- natselection
-
Topic Author
- Offline
7 years 10 months ago #299842
by natselection
Replied by natselection on topic Content Module Product Number
I think I understand what you mean. I'll give it a try but I suspect I may end up running into a new issue with how we have custom fields setup for product specifications that are different based on category.
Please Log in or Create an account to join the conversation.
7 years 10 months ago #299844
by nicolas
Replied by nicolas on topic Content Module Product Number
Hi,
Normally, if the category attached to the product is outside of the category tree of the menu item, it shouldn't be taken into account.
So it should be possible to link the products to the custom fields through the categories, either directly if the custom fields-product links follow your category structure, or with categories outside of the browsable category structure.
Note also that for a custom product field, even if you don't restrict it to categories/products, it will only appear on the product page on the frontend if you set something in it. If you leave the field empty, it won't appear.
So the restriction on the categories/products for the custom product fields is more of an aid for the setup of the products in the backend than something useful on the frontend.
Normally, if the category attached to the product is outside of the category tree of the menu item, it shouldn't be taken into account.
So it should be possible to link the products to the custom fields through the categories, either directly if the custom fields-product links follow your category structure, or with categories outside of the browsable category structure.
Note also that for a custom product field, even if you don't restrict it to categories/products, it will only appear on the product page on the frontend if you set something in it. If you leave the field empty, it won't appear.
So the restriction on the categories/products for the custom product fields is more of an aid for the setup of the products in the backend than something useful on the frontend.
Please Log in or Create an account to join the conversation.
- natselection
-
Topic Author
- Offline
7 years 10 months ago #299965
by natselection
Replied by natselection on topic Content Module Product Number
I ended up just pulling all of the subcategories out into a flat list of categories. That turned out to be the only combination with our setup that worked across the different features without causing issues somewhere else.
Thanks for the help Nicolas.
Thanks for the help Nicolas.
The following user(s) said Thank You: Philip
Please Log in or Create an account to join the conversation.
Time to create page: 0.218 seconds