Put this code in your CMS homepage
Create a new file under app/design/frontend/default/<your theme="">/template/catalog/image.phtml
{{block type="catalog/product_list" template="catalog/image.phtml"}}
Create a new file under app/design/frontend/default/<your theme="">/template/catalog/image.phtml
<?php
//to get category id & name
$helper = Mage::helper('catalog/category');
$collection = $helper->getStoreCategories('position', true, false);
$array = $helper->getStoreCategories('name', false, false);
$categoryCount = 0;
// echo "<pre>";print_r(get_class_methods($collection));
echo "<table width='750' cellpadding='0' cellspacing='0' border='0' align='center'>";
foreach ($collection as $cat):
$Mcategory = Mage::getModel('catalog/category')->load($cat->getEntityId());
if(($Mcategory->getLevel() == 2) && ($Mcategory->getImageUrl()))
{
if($categoryCount % 4 == 0)
{
echo "<tr>";
}
$categoryCount++;
echo "<td width='245'>";
echo "<div>
<a href=". $cat->getUrl() ." ><img src=".$Mcategory->getImageUrl()." align='middle' width='125px' height='105px' /></a>
</div>
<p><a style='color:#5C5C5C; font-weight:bold; text-decoration:underline; font-size:13px;' href=".$cat->getUrl()." >". $cat->getName()."</a></p>
<td>";
if($categoryCount % 4 == 0)
{
echo "</tr>";
}}
endforeach;
echo "</table>";
?>
I tried this, But nothing appears in homepage,
ReplyDeleteI am using magento 1.5
please help
Its working for me. I checked with magento version 1.5.1.0. Make sure you have Uploaded category images under admin -> catalog -> Manage categories -> Your category -> Image. Then clear the cache and check.
ReplyDelete