Know Magento

yet another magento blog

Add Manufacturer block in Magento

To add the Manufacturer block in Magento is very easy. Just follow the steps mentioned bellow.

Create a new template file manufacturer.phtml  in app/design/frontend/default/<your_template>/template/catalog/navigation/
(if you are not able to find catalog or navigation directory in template then please create them in respective order)

Put the following code in  manufacturer.phtml

<ul>
<?php
$collection = Mage::getResourceModel('catalog/product_attribute_collection') ->addFieldToFilter('attribute_code', array('eq'=>'manufacturer'))
->addStoreLabel(Mage::app()->getStore()->getId())
->load();

foreach($collection as $a){
$manufArray = $a->getSource()->getAllOptions(false);
foreach($a->getSource()->getAllOptions(false) as $option)
$manufArray[$option['value']] = $option['label'];
}
asort($manufArray);
foreach($manufArray as $menKey => $menVal)
{
if(is_array($menVal))
{
continue;
}

echo '<li><a href="'.Mage::getURL().'catalogsearch/advanced/result/?manufacturer%5B%5D='.$menKey.'">'.$menVal.'</a></li>';
}
?>
</ul>

If you want to add block in your right or left column on your site add the following code in  app/design/frontend/default/<your_template>/layout/local.xml

<?xml version="1.0"?>
<layout version="0.1.0">
	<default>
	<reference name="left">
			<remove name="left.newsletter" />
			<block type="catalog/navigation" name="catalog.leftmenufecture" template="catalog/navigation/manufacturer.phtml" />
	</reference>
	</default>
</layout>

If you want to add block in CMS based page add the following code in CMS > Edit page > Content

{{block type="catalog/navigation" name="catalog.leftmenufecture" template="catalog/navigation/manufacturer.phtml"}}

Leave a comment