How can I retrieve a product collection by a root category and from all its subcategories?
Eg:
Root Category (2 products)
- Subcategory 1 (2 products)
- Subcategory 2 (3 products)
So I want to retrieve all 7 products in the collection.
categorycollection;magento2product
How can I retrieve a product collection by a root category and from all its subcategories?
Eg:
Root Category (2 products)
So I want to retrieve all 7 products in the collection.
Best Answer
You can use like this:
*Note: Your category must Enable Anchor
*Note: run
php bin/magento indexer:reindex
just for make sure