Monday, September 19, 2011

How to show all the manufactures or brand list in magento left sidebar?

create a manufacturers.phtml file under "app/design/frontend/default/YOURTHEME/template/catalog/product"
<?php
/*
 * Manufacturers Listing on sidebar
 * @category    design
 * @package     base_default
 */
?>

<div>
  <div>
    <h4><span>Our Brands</span></h4>
  </div>
  <div>
  <?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 Mage::getBaseUrl(); ?>catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a></li>
      <?php endforeach; ?>
    </ul>
  </div>
  <div></div>
</div> 
Add the below code in your "/app/design/frontend/default/YOURTHEME/layout/catalog.xml" file.



Thats it you are done.

No comments:

Post a Comment