Author Topic: Load products from all levels of sub-categories  (Read 416 times)

idor

  • Jr. Member
  • **
  • Posts: 66
Load products from all levels of sub-categories
« on: April 08, 2020, 00:17:53 am »
Hello,
I use Joomla 3.9.15 & VirtueMart 3.6.10 10211
I have a website with a category tree with 3, 4 levels of categories  (or maybe more), and millions of products.
I want to show all products from subcategories in their parent page.
I enabled "Show products of subcategories" from VM configuration > shopfront
but I only get the products of second level in the first parent.
What I need is to load ALL products from ALL levels.
ej. Cat.1
            >Cat.1.a & Cat. 1.b
                                        >Cat1.a.i & Cat1.a.ii & Cat. 1.b.i & Cat. 1.b.ii>...etc


When I click from the menu Cat.1 I need to load products from all sub-categories and sub-sub-categories.

Now I get products only from Cat.1.a & Cat. 1.b

Could anyone help with this?

Thank you!

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1404
Re: Load products from all levels of sub-categories
« Reply #1 on: April 08, 2020, 14:06:40 pm »
Hi

I would not recommend to do that. It has to run several sub-queries in your parent category's page that will make it very "heavy".
Fist have to find all the sub-categories of each node and then get the products of each node. This has to be done for each node of your tree.

Instead my suggestion is to assign your products to your parent category as well and disable the setting "Show products of subcategories".
If you have concerns about SEO, please use the "canonical category" to set the product's main category.

idor

  • Jr. Member
  • **
  • Posts: 66
Re: Load products from all levels of sub-categories
« Reply #2 on: April 08, 2020, 15:04:00 pm »
I need to do this through PHP, because assigning the product in more than one category, the breadcrumbs are messing up.