I want to show category product count which is shown in admin after the category name.
As of now I write this code but it's not working properly.
$category->getProductCollection()->count();
Please see the image to get better idea.
Magento Backend
Magento Frontend
Best Answer
Not sure if this is still relevant but answering it anyway. The answer post by @Jean Paul CP is correct.
$category->getProductCount();
return exactly the count which shown in the admin panel categories listing. On the other hand$category->getProductCollection()->count();
only returns count of active saleable products in the category.