Magento: Add categories with images on homepage

Follows the below steps to displaying all categories with images on homepage:


Step1 : Add the code below to your homepage content from admin cms-> pages.

{{block type="catalog/navigation" name="catalog.category" template="catalog/category/list.phtml"}}

Step2:Create a list.phtml file under “/app/design/frontend/yourpackage/yourtheme/template/catalog/category/list.phtml” and add the below given code :

<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $open
= $this->isCategoryActive($_category); ?>
<?php
$cur_category
=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
if (
$immagine = $this->getCurrentCategory()->getImageUrl()):
?>
<div style="float: left; padding-right: 30px; text-align: center;">
<
div class="linkimage">
<
p>
<
a href="<?php echo $this->getCategoryUrl($_category)?>">
<
img src="<?php echo $immagine ?>" alt="<?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?>" width="135" height="135" />
<?php echo $_category->getName()?>
</a>
</
p>
</
div>
</
div>
<?php endif; ?>
<?php
endforeach; ?>



Step3: Clear Cache.


Step4: Done.

Magento: Add categories with images on homepage Magento: Add categories with images on homepage Reviewed by Web Technology Funda on 12:36:00 AM Rating: 5

2 comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thank you so much Malli... Your site is also Rocking. Good information about Govt. jobs!!!

    ReplyDelete

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!