Magento’s integrated function
getProductCount() also counts invisible/inactive products. If your theme displays product counts next to each category (e.g. in the top menu or category blocks), this can be very confusing for your customer.
If your category product count shows 10 products, but 6 are set to invisible. Your customer wil end up very disappointed to see only 4 products in the product list.
Today I will show you how to display only visible/active products in your Magento theme’s category product count.