I'm currently working on a site with a large amount of products (approx 1500) and I'm attempting to display all product within a category but also any child categories. Currently I'm doing this recursively.
So adding products from my current category then seeing if that category has any children, and looping round this method. This approach is currently very slow at pulling the data out I was wondering is there a better way of doing this or is there any built in query for this.
Managed to speed this up greatly by initially getting a list of the category id's then doing a Linq query for products that have a category product relation to any of the matching categories.
Sorry, probably not explained this very well. My parent category doesnt have any products added to it. I have a parent/child hierarchy of products with all products sitting in the child categories.
I suppose the easy solution would be to mae sure the parent categories are checked in uCommerce. Is this best practice or is anyone using any other methods to list products within a category and all child categories?
uCommerce 3 get all products from category and sub categories.
Hi,
I'm currently working on a site with a large amount of products (approx 1500) and I'm attempting to display all product within a category but also any child categories. Currently I'm doing this recursively.
So adding products from my current category then seeing if that category has any children, and looping round this method. This approach is currently very slow at pulling the data out I was wondering is there a better way of doing this or is there any built in query for this.
Thanks,
John
Managed to speed this up greatly by initially getting a list of the category id's then doing a Linq query for products that have a category product relation to any of the matching categories.
John
Hi John,
Thanks for being aweome and posting the solution on the forum.
Hi John,
I need to also list all products sitting under a parent category. I am a bit new to linq, any chance you can post your linq command?
Cheers,
Marc
Hi Marc,
If you have the current category you can just go:
John
Hi John,
Sorry, probably not explained this very well. My parent category doesnt have any products added to it. I have a parent/child hierarchy of products with all products sitting in the child categories.
Parent
--Child
--Child
Parent
--Child
--Child
--Child
I want to be able to click on the parent category from the menu and display all products that sit in the child categories below it.
Cheers,
Marc
I suppose the easy solution would be to mae sure the parent categories are checked in uCommerce. Is this best practice or is anyone using any other methods to list products within a category and all child categories?
Cheers,
Marc
No we don't have all the parent categories checked. What I do is:
1. From my current category do a recurssive loop to get all child/sub child categories Id.
2. Do a search against all products to find any that have a CategoryProductRelations with any of the categories in our list.
John
is working on a reply...