How to Display Configurable Product Options in Category List Page in Magento 1

configurable-productmagento-1

How to check that Displaying configurable product options in category list page?

Best Answer

In order just to display all sale able options in the category go to .../app/design/frontend/[package]/[theme]/template/catalog/product/list.phtml and place within foreach ($_productCollection as $_product) something like this:

<?php if($_product->isConfigurable()): ?>
  //get attributes
  <?php $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
  <?php if(count($attributes)): ?>
    <ul>
    <?php foreach($attributes as $att): ?>
      <?php $pAtt=$att->getProductAttribute();
        //get the child products
        $allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
        $frontValues =array() ?>
      <li><?php echo $pAtt->getFrontendLabel() ?>
       <ul>
       <?php foreach($allProducts as $p): ?>
         //check stock, status, ...
         //do not show unsaleable options
         <?php if(!$p->isSaleable()) continue; ?>
         <?php $out=$p->getAttributeText($pAtt->getName()); ?>
         <?php $frontValues[$out]=$out; ?>
       <?php endforeach ?>
        <li><?php echo implode('</li><li>', $frontValues) ?></li>
       </ul>
      </li>
    <?php endforeach ?>
    </ul>
  <?php endif ?>
<?php endif ?>

Perhaps you like to add some css classes to the <ul> and <li> tags.

This won't increase the performance of your shop!

inspired by this Post

http://www.magentocommerce.com/boards/viewthread/73926/#t437146

Related Topic