Saturday 9 July 2011

Magento 'Shop By Brand' in SideBar

First create the template file and name it productbrand.phtml place it in catalog/product folder

copy the code given below and paster it in you productbrand.phtml

Note: Please chnage 'yourdomain.com' with your site domain name

<div>
<div>
<h4>
<span>Product Brands</span></h4>
</div>
<div style="padding-left:8px;">

<?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="http://www.yourdomain.com/catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a>
</li>
<?php endforeach; ?>   </ul>
</div>
<div>
</div>
</div>

1 comment:

  1. Your piece of code helped me while working on SHOP BY BRAND feature for improved navigation module for Amasty(http://amasty.com/improved-navigation.html). your post is really helpfull! continue to do this

    ReplyDelete