Reshu
Reshu

Reputation: 67

Magento: How to show configurable product options in product list page?

How to show configurable product options in product list page?

I want to show the configurable product options as a dropdown in product list page itself.After select the option price should be changed automatically.

Thanks in advance.

Upvotes: 2

Views: 9946

Answers (2)

am_skp
am_skp

Reputation: 317

Hi i think this tutorial will help u... http://www.catgento.com/adding-configurable-product-options-to-category-list-in-magento/

Upvotes: 0

Dushyant Joshi
Dushyant Joshi

Reputation: 3702

Go to app/design/frontend/YOUR_package/YOUR_theme/template/catalog/product/list.phtml and place under foreach ($_productCollection as $_product) below code:

<?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 ?>

Upvotes: 3

Related Questions