Magento: Artikel filtern nach bestimten Parametern
Artikel könnt ihr wie folgt nach bestimmten Parametern filtern. Folgendes Beispiel zeigt die Filterung anhand des Preises aus bestimmten Unterkategorien:
<?php
$model = Mage::getModel('catalog/product'); // Direktzugriff auf Produkt als Methode
$collection = $model -> getCollection(); //Zugrif auf Eigenschaft
$collection -> addAttributeToSelect('name'); //Attributaktivierung - Name
//$collection -> load(); //Zeigt alle Artikel
$collection -> addFieldToFilter('price',array('from'=>'0','to'=>'40')); //Filtert alle Artikel von 0 bis 40€.
$collection -> getSelect();
$collection -> setOrder('price', 'ASC');
?>
<ul><?php foreach($collection as $product) : ?>
<li>
<?php echo $product ->getPrice(); echo "€ - "; ?>
<?php echo $product ->getName(); echo " - ";?>
<?php echo $product ->getColor(); echo " ";?>
</li>
<?php endforeach; ?>
</ul>


One Comment