I have a category named "More" and it has 400 products in main store view, but in one sub store no products assigned from this category. But when I'm trying to get product count on sub store frontend for this category, it is returing 400 but it should be 0.

My code is as below :

$_category = $this->_categoryFactory->create();
echo $category->getProductCount();

I also tried ->setStore($this->_storeManager->getStore()) but doesn't work.

How can I get correct product count on sub store view?

1 Answer 1


Please check https://github.com/magento/magento2/issues/4767#issuecomment-289673132 may be it'll help you.

  • Thanks for your hint, $category->getProductCollection()->count() is returning correct count. Commented Mar 7, 2018 at 11:14

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.