Is it possible to get a count of the total number of associated products assigned to a configurable product?
I have tried using the following functions:
getConfigurableAttributesAsArray()
getProductCount()
count()
However, I've only seen this working when applied to categories, not configurable products. While I do want to output the count in list.phtml
, I want to output it per product, not for the entire category.
Best Answer
While the approach offered by jigs parmar does work, it is a HUGE performance hit if used in a loop! A much better approach is:
The reason is that
getUsedProducts()
returns every simple product along with every attribute of those products. In a loop, that took forever!Since I only needed the number of products, I could use
getChildrenIds()
which only returns the ID of the simple products--much lighter code!