941-685-8851

‘category thumbnails’

Magento 1.6 category thumbnails on home page

It is often desirable to display categories on the home page opposed to products, then display the products on the respective category page. To add categories along with thumbnaile images on the homepage paste the following code into your homepage from the Magento Admin: CMS > Pages > Home.
{{block type=”catalog/navigation” name=”catalog.category” template=”catalog/category/list.phtml”}}

Create a list.phtml file in your Magento template files at: /app/design/frontend/default/default/template/catalog/category/list.phtml .
Paste the following code into this new list.phtml page:

<?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()->
getThumbnailUrl()):
?> <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; ?>
Now create a getThumbnailUrl function at App/Code/Core/Mage/Catalog/Model/category.php line 490, after getImageUrl() :

public function getThumbnailUrl()
{
$url = false;
if ($image = $this->getThumbnail()) {
$url = Mage::getBaseUrl('media').'catalog/category/.$image;
}
return $url;
}

Then upload a thumbnail image at Catalog > Manage Categories >
Share