2017-01-11 1 views
0

Ich habe erfolgreich alle Sammlung von Produkten und Produkt-Attribut Wert von einer bestimmten Kategorie ID angezeigt. Ich kann jedoch nicht herausfinden, wie das Label für das Produktattribut angezeigt wird. Die Attributbezeichnungen sind fest codiert, aber ich möchte, dass sie automatisch generiert werden.Zeigen Sie alle Produkt, Produkt-Attribut Wert und Attribut-Label der spezifischen Kategorie ID in Magento

Wie kann ich alle Produktattributwerte und ihre jeweiligen Labels anzeigen, die am Frontend angezeigt werden dürfen?

Bisher ist es das, was ich

<?php 
$idValue = 10; 
$catagory_model = Mage::getModel('catalog/category')->load($idValue); //where $category_id is the id of the category 
$collection = Mage::getResourceModel('catalog/product_collection'); 
$collection->addCategoryFilter($catagory_model); //category filter 
$collection->addAttributeToFilter('status',1); //only enabled product 
$collection->addAttributeToSelect('*'); //add product attribute to be fetched 
$collection->addStoreFilter(); 
?> 
<table class="full-width-tbl"> 
<thead> 
    <tr> 
     <th>Part Number</th> 
     <th>Model</th> 
    </tr> 
</thead> 
<tbody> 
<?php foreach ($collection as $_product): ?>    
    <tr itemscope itemtype="http://schema.org/IndividualProduct"> 
     <td itemprop="name" style="display:none;"><?php echo $_product->getPart_number() ?></td> 
     <td itemprop="sku"><?php echo $_product->getModel() ?></td> 
    </tr> 
<?php endforeach ?> 
</tbody> 
</table> 

Antwort

1

die Sie interessieren haben:

Dies wird Ihnen Attributelabel-Attributecode-Attributevalue

<?php foreach ($collection as $_product): 

    $product_id = $_product->getId(); 
    $product = Mage::getModel('catalog/product')->load($product_id); 
    $attributes = $product->getAttributes(); 


    foreach ($attributes as $attribute) { 
      $visibility = $attribute->getIsVisibleOnFront(); 
      $attributeLabel = $attribute->getFrontendLabel(); 
      $attributeValue = $attribute->getFrontend()->getValue($product); 
      $attributeCode = $attribute->getAttributeCode(); 
if($visibility){   
echo $attributeLabel . '-' . $attributeCode . '-' . $attributeValue; echo "<br />"; }  

    } 
    endforeach 
    ?> 
+0

diese alle Attribute holen, wie ich es nur sortieren Anzeige der auf der Produktansicht sichtbaren Seite auf Front-End auf ja? – rodge

+0

Danke! Problem gelöst. – rodge

Verwandte Themen