• By Pushpendra Singh
  • December 16, 2011
  • Magento
How to get manufacturers list : Magento

If you want to show the manufacturers list on your sidebar or anywhere else in magento site.  You just need add some little code.

First open the file app/code/core/Mage/Catalog/Block/Navigation.php

Add the below code at the end of file

public function getAllManu()
{
$product = Mage::getModel(‘catalog/product’);
$attributes = Mage::getResourceModel(‘eav/entity_attribute_collection’)
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter(‘attribute_code’, ‘manufacturer’); //can be changed to any attribute
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);

return $manufacturers;
}

Now put below code in your theme file where you want to show the list. Foe example if you want to show the manufacturer  list on top navigation. Then open app/design/frontend/defaultyour-theme-name/template/catalog/navigation/top.phtml

Add the below code where you want to show the list:

<ul>
<?php foreach ($this->getAllManu() as $manufacturer): ?>
<li><a href=”<?php echo $this->getUrl() ?>/catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer[‘value’] ?>”><?php echo $manufacturer[‘label’] ?></li>
<?php endforeach; ?>
</ul>

You can use the above process to call / show other attributes. But i would like to suggest you one thing “don’t make any change on magento core file”. You can make a custom module for it. Really simple way to do this make a Root Category” and “Sub category” and call subcategory for it. If you want how it can be done, please refer “How to get sub category list for specific category in magento“.