0

For reasons I will not go into (inheriting an old code base), I need to find the product count of a specific category subject to the current facet.

Say I am on the category page, and I have loaded a list of child categories. I would like to find the product count for each sub-category based upon the current facet selections. All of this needs to be done without using the standard facet nav implementation.

1 Answer 1

1

So you have the categories collection $categories and current facet selection in the $layer object.

Then you can just call do

$layer->getProductCollection()
      ->addCountToCategories($categories);

and then get the counts like

        foreach ($categories as $category) {
            echo $category->getProductCount()) {
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.