<?php
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
?>
<ul id="manufacturer_list">
<?php foreach ($manufacturers as $manufacturer): ?>
<li><a href="<?php echo $this->getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a></li>
<?php endforeach; ?>
</ul>
Get list of all Manufacturers with product count
<?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); ?>
<ul id="manufacturer_list">
<?php
foreach ($attributeOptions as $_option){ ?>
<li><a href="<?php echo $this->getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=<?php echo $_option['value'] ?>"><?php echo $_option['label'] ?></a>
<?php
$productcollection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter($name, $_option['value']);
echo count($productcollection); ?>
</li><?php
}
?>
</ul>
0 Comments