love the helpful resources here. This seems so simple but I'm getting stumped on it.

The concept is simple, I think - each of my items for sale have configurable flavors. One item may have 5 flavors, the next may have 2. I'm not looking to display all of those flavors, but simply include "5 Flavors" or "2 Flavors" under each product on the list page.

Here's my code so far...

                <?php if($_product->isConfigurable()): ?>
                    <?php // get attributes ?>
                    <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
                    <?php if(count($attributes)): ?>
                        <span class="flavor_count"><?php echo count($attributes); ?> Flavors</span>
                    <?php endif;?>
                <?php endif;?>

If you're looking for a way to display the number of single products associated to a configurable one, this code might help:

    $varietiesCount = 0;
    if ($_product->isConfigurable()) {
        foreach (Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$_product) as $_single) {
            if ($_single->isSaleable()) {
    echo $varietiesCount;

What it does is to load all associated simple products, check if each of them is saleable and increment counter. You might want to add some logic to displaying the amount (check for 0, add text), but this would be the starting point.

Please note that this method is not optimal performance-wise. It should however get the job done.

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.