<?php
$name = 'manufacturer';
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
$attributeId = $attributeInfo->getAttributeId();
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attributeOptions = $attribute ->getSource()->getAllOptions(false);
foreach ($attributeOptions as $_option){
echo $_option['label'];
$productcollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter($name, $_option['value']);
foreach ($productcollection as $_product){
echo $_product->getName();
}
}
?>
Categories: Magento
0 Comments