Wednesday 9 January 2013

code to show category images on custom phtml files and link to their category pages

<?php

 $root_category = Mage::getModel('catalog/category')->load(2); // Put your root category ID here. like 2
$subcategories = $root_category->getChildren();
foreach(explode(',',$subcategories) as $subcategory) {
$category = Mage::getModel('catalog/category')->load($subcategory);
echo'<pre>';
//print_r($category);
echo  $category->getImageUrl(); //place this url in your image tag to show the image

  }

  ?>

No comments:

Post a Comment