I’ve been driving myself crazy trying to display thumbnail images for a list of sub categories I’m attempting to display in a footer. I’ve tried the solution found here: http://www.douglasradburn.co.uk/getting-category-thumbnail-images-with-magento/ but no luck!
Here is the code I am using at the moment. Everything works fine apart from the img src renders empty:
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan):
?>
<li>
<a href="<?= $artisan->getUrl() ?>" title="<?= $artisan->getName() ?>"><img src="<?= $artisan->getThumbnailUrl() ?>" /></a>
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
Any help would be greatly appreciated! Thanks in advance.
SOLUTION (thanks Lucasmus!):
<? $artisans = Mage::getModel('catalog/category')->load(9)->getChildrenCategories(); ?>
<ul class="artists">
<? $i = 0; foreach($artisans as $artisan): ?>
<li>
<a href="<?= $artisan->getUrl() ?>" title="<?= $artisan->getName() ?>"><img src="<?= Mage::getBaseUrl('media').'catalog/category/'.$artisan->load($artisan->getId())->getThumbnail() ?>" width="96" height="96" /></a>
</li>
<? if(++$i > 7) break; endforeach; ?>
</ul>
There is a good chance that there is not enough information loaded from the childcategory. It could help if you added
$artisan->load($artisan->getId());before getting the actual variables from the$artisan.