1

I wrote a little piece of code that shows me the amount of products in a category. However, after applying filters through one of the Amasty extensions, the count is incorrect and stays at the original.

<?= $helper->getCurrentCategory()->getProductCollection()->count(); ?>

That's how the count is shown. Below is the definition of getCurrentCategory().

public function getCurrentCategory(){
    return $this->registry->registry('current_category');
}

Is there any way to update the count after a filter has been applied?

Thanks!

1

I might be missing the root issue you're trying to solve, but I don't believe the getCurrentCategory() takes into account applied filters. I'd expect you to get the results you're currently getting because the count of products in that category will never change when its being filtered. Filtering just narrows the number of products displayed. It doesn't decrease the number of products in the category.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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