I am stuck at this point. I want to display a grid of categories thumbnail/image

var_dump($_category->getData('thumbnail')); return NULL

Even when I do var_dump($_category->getData()); here is what's return

array(16) { ["entity_id"]=> string(1) "3" ["entity_type_id"]=>string(1) "3"     
["attribute_set_id"]=> string(1) "3" ["parent_id"]=> string(1) "2" 
["created_at"]=> string(19) "2014-12-15 18:49:50" ["updated_at"]=> string(19) 
"2014-12-15 19:09:30" ["path"]=> string(5) "1/2/3" ["position"]=> string(1) 
"1" ["level"]=> string(1) "2" ["children_count"]=> string(1) "0" ["path_id"]=> 
string(5) "1/2/3" ["is_active"]=> string(1) "1" ["include_in_menu"]=> 
string(1) "1" ["request_path"]=> string(14) "vegetable.html" ["name"]=> 
string(9) "Vegetable" ["url_key"]=> string(9) "vegetable"}

this is my code

<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php if (count($_categories) > 0): ?>
    <?php foreach($_categories as $_category): ?>
            <a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
                <?php echo $_category->getName(); // this works?>
                <?php var_dump($_category->getData('thumbnail')) // return null?>
    <?php endforeach; ?>
<?php endif; ?>

5 Answers 5


You could use

echo Mage::getModel('catalog/category')->load($catId)->getThumbnailImageUrl();

But you would have to make some changes to


Before editing, copy this file to local and then insert the following code around line 494

 * Retrieve Thumbnail image URL
 * @return string
public function getThumbnailImageUrl()
    $url = false;
    if ($image = $this->getThumbnail()) {
        $url = Mage::getBaseUrl('media').'catalog/category/'.$image;
    return $url;
  • 1
    Do not extend the core like this please...
    – Alex
    Mar 15, 2017 at 15:11

Please use this code:

$catId = 566;
$imageName = Mage::getModel('catalog/category')->load($catId)->getImage();
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
echo $mediaUrl.'catalog/category/'.$imageName;

I found an answer


will get the image file name, but i need to use


I needed to get category thumbnail inside _getHtml() (Mage_Page_Block_Html_Topmenu).

First, inside observer (Mage_Catalog_Model_Observer) _addCategoriesToMenu(...) function I added 'thumbnail' to $categoryData array.

$categoryData = array(
                'name' => $category->getName(),
                'id' => $nodeId,
                'url' => Mage::helper('catalog/category')->getCategoryUrl($category),
                'is_active' => $this->_isActiveMenuCategory($category),
                'thumbnail' => $category->getThumbnail()

Second, as mentioned by michael above I added <thumbnail/> attribute in Mage/Catalog/etc/config.xml -> frontend/category/collection/attributes.

Now, each $child object in the foreach loop of _getHtml() function contains "thumbnail" data attribute with image name (if present).


You can add <thumbnail/> in app/code/core/Mage/Catalog/etc/config.xml -> frontend/category/collection/attributes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.