<?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&#91;'value'&#93; ?>"><?php echo $manufacturer&#91;'label'&#93; ?></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&#91;'value'&#93; ?>"><?php echo $_option&#91;'label'&#93; ?></a>
  <?php
    $productcollection = Mage::getModel('catalog/product')->getCollection()
        ->addAttributeToSelect('*')
        ->addAttributeToFilter($name, $_option['value']);
        echo count($productcollection); ?>
    </li><?php
    
}
?>
 </ul>

Categories: Magento

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *