Frage

Wie überprüfen Sie die Anzeige konfigurierbarer Produktoptionen auf der Kategorienlistenseite?

War es hilfreich?

Lösung

Um nur alle verkaufabfähigen Optionen in der Kategorie anzuzeigen, gehen Sie zu .../app/design/frontend/[package]/[theme]/template/catalog/product/list.phtml und innen platzieren foreach ($_productCollection as $_product) etwas wie das:

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

Vielleicht fügen Sie gerne einige CSS -Klassen zu dem hinzu <ul> und <li> Stichworte.

Dies wird die Leistung Ihres Ladens nicht erhöhen!

Inspiriert von diesem Beitrag

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

Andere Tipps

Sie können so etwas verwenden if ($_product->getTypeId() == 'configurable') Innerhalb Ihres Produktsschleifs.

Dies kann beträchtliche Serverressourcen aufnehmen, da für jedes Produkt viele Optionen vorhanden sind. Der beste Weg ist es, AJAX zu verwenden, um nur alle Optionen zu laden, wenn sie gefragt werden. Ich habe diese Erweiterung gefunden, die zuerst die Farben lädt. Wenn Sie darüber maust, erhalten Sie alle Produktoptionen.

http://www.consofas.com/plugins/options-quickview-for-configurable-products-in-magento/

Versuchen Sie das einmal

<?php $ptype = $_product->getTypeId();?>
<?php 
                                                if($ptype=='configurable'): ?>
                                                <!--get attributes-->
                                                <?php 
                                                $attributes = $_product->getTypeInstance(true)->getConfigurableAttributes($_product) ?>
                                                <?php 
                                                if(count($attributes)): ?>
                                                <?php 
                                                    foreach($attributes as $att): ?>
                                                    <?php 
                                                        $pAtt=$att->getProductAttribute();
                                                        //get the child products
                                                        $allProducts = $_product->getTypeInstance(true)->getUsedProducts($_product,null);
                                                        $frontValues =array();
                                                        foreach($allProducts as $p):
                                                            if($p->isSaleable()):
                                                                $attributeExist =$_product->getResource()->getAttribute($pAtt->getName());
                                                            ?>
                                                                <input type="hidden" name="super_attribute[<?php echo $pAtt->getAttributeId() ?>]" value="<?php  echo $attributeExist->getSource()->getOptionId($p->getAttributeText($pAtt->getName()));?>">
                                                            <?php
                                                                break;
                                                            endif;
                                                        endforeach;
                                                    endforeach;
                                                endif;
                                                    ?>
                                                <?php
                                                endif;
                                                ?>

Der folgende Link kann Ihnen helfen.

http://hkpatel201.blogspot.in/2012/09/get-product-custom-option-in-list-page.html

Durch den Code gehen

Vielen Dank

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top