How to Get Thumbnail of Subcategory in a Loop

imagethumbnail

$category = Mage::getModel('catalog/category')->load('2')->getChildrenCategories();
foreach ($category as $cat){

    $entity_id = $cat->getId();
    $name = $cat->getName();
    $url_key = $cat->getUrlKey();
    $url_path = $cat->getUrlPath();
    $skin_url = $cat->getImageUrl(); 


 <img src="<?php echo $skin_url; ?>" />

above mentioned code is not working for me, if any one have to the point solution, then please help.

Best Answer

Try it like this:

$categories = Mage::getModel('catalog/category')->getCollection()
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('parent_id', 2);

foreach ($categories as $cat) {
    $entity_id = $cat->getId();
    $name = $cat->getName();
    $url_key = $cat->getUrlKey();
    $url_path = $cat->getUrlPath();
    $skin_url = $cat->getImageUrl(); 
    echo '<img src="'.$skin_url.'" />';
}
Related Topic