show manufacturer on Home Page


<?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>

<?php foreach ($manufacturers as $manufacturer): ?>
<?php  $bid = $manufacturer[‘value’]; ?>
<?php /*?><li><a href=”<?php echo $currentUrl ?>?manufacturer=<?php echo $manufacturer[‘value’] ?>”><?php echo $manufacturer[‘label’] ?><?php echo $manufacturer[‘value’] ?></a></li><?php */?>

<?php
$products = Mage::getModel(‘catalog/product’)->getCollection();
$products->addAttributeToFilter(‘manufacturer’, array(‘in’ => array($bid)));
$products->addAttributeToSelect(‘*’);
$products->load(); ?>

<li><?php echo $manufacturer[‘label’] ?>(<?php echo $products->count() ?>) </li>

<ul class=”brand-products”>
<?php
$i = 0;
foreach($products as $_prod)
{
echo $_cat_name = $_prod->getCategory(); ?>

<li>
<a href=”<?php echo $_prod->getProductUrl() ?>” title=”<?php echo $this->stripTags($this->getImageLabel($_prod, ‘small_image’), null, true) ?>” class=”product_img_link”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_prod, ‘small_image’)->resize(200); ?>” width=”200″ height=”200″ alt=”<?php echo $this->stripTags($this->getImageLabel($_prod, ‘small_image’), null, true) ?>” />
<a href=”<?php echo $_prod->getUrlPath() ?>”><?php echo $_prod->getName()?>
<?php echo $_cat_name; ?></a>
<span class=”price”><?php echo $_prod->getFormatedPrice()?></span>

</li>
<?php } ?>
</ul>

<?php endforeach; ?>
</ul>

<?php /*?><select class=”choose-sel” name=”computer_manufacturers” id=”brand_name” onchange=”submit();”>
<option value=”select”>choose your brand</option>
<?php foreach ($manufacturers as $manufacturer): ?>
<option value=”<?php echo $manufacturer[‘value’] ?>”><a href=”<?php echo $currentUrl ?>?manufacturer=<?php echo $manufacturer[‘value’] ?>”><?php echo $manufacturer[‘label’] ?></a></option>
<?php endforeach; ?>
</select><?php */?>

<?php /*?><?php
$bid = 5; // the brand / manufacturer ID

$products = Mage::getModel(‘catalog/product’)->getCollection();
$products->addAttributeToFilter(‘manufacturer’, array(‘in’ => array($bid)));
$products->addAttributeToSelect(‘*’);
$products->load();
echo $products->count() ?>

<ul class=”brand-products”>
<?php
$i = 0;
foreach($products as $_prod)
{
echo $_cat_name = $_prod->getCategory(); ?>

<li>
<a href=”<?php echo $_prod->getProductUrl() ?>” title=”<?php echo $this->stripTags($this->getImageLabel($_prod, ‘small_image’), null, true) ?>” class=”product_img_link”><img src=”<?php echo $this->helper(‘catalog/image’)->init($_prod, ‘small_image’)->resize(200); ?>” width=”200″ height=”200″ alt=”<?php echo $this->stripTags($this->getImageLabel($_prod, ‘small_image’), null, true) ?>” />
<a href=”<?php echo $_prod->getUrlPath() ?>”><?php echo $_prod->getName()?>
<?php echo $_cat_name; ?></a>
<span class=”price”><?php echo $_prod->getFormatedPrice()?></span>

</li>
<?php } ?>
</ul><?php */?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s