Question

I am currently getting category image with the following code:

   <li class="item <?= $class ?> sub-cat-items">
       <a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->
        htmlEscape($_category->getName()) ?>"><img src="<?php echo
        $_category->getImageUrl() ?>" width="580" alt="<?php echo
        $this->htmlEscape($_category->getName()) ?>" /></a>
        <h1><?php echo
        $this->htmlEscape($_category->getName()) ?></h1>
   </li>

But i want to get thumbnail instead of main category image i have tried like this but not working:

       <?php
       $_categories = $this->getCurrentChildCategories();
        if ($_categories->count()):
        $categorycount = 0;
          foreach ($_categories as $_category):
           if ($_category->getIsActive()):
          $cur_category =  Mage::getModel('catalog/category')->load($_category->getId());
        $layer = Mage::getSingleton('catalog/layer');
        $layer->setCurrentCategory($cur_category);
        $catName = $this->getCurrentCategory()->getName();
        if ($categorycount == 0) {
            $class = "first";
        } elseif ($categorycount == 3) {
            $class = "last";
        } else {
            $class = "";
        }
      echo Mage::getModel('catalog/category')->load($cur_category)->getThumbnailImageUrl(). 'echo';
   ?>
Was it helpful?

Solution

     <?php
           $_categories = $this->getCurrentChildCategories();
            if ($_categories->count()):
            $categorycount = 0;
              foreach ($_categories as $_category):
               if ($_category->getIsActive()):
              $cur_category =  Mage::getModel('catalog/category')->load($_category->getId());
            $layer = Mage::getSingleton('catalog/layer');
            $layer->setCurrentCategory($cur_category);
            $catName = $this->getCurrentCategory()->getName();
            if ($categorycount == 0) {
                $class = "first";
            } elseif ($categorycount == 3) {
                $class = "last";
            } else {
                $class = "";
            }
// Updated Code Here 
          echo Mage::getBaseUrl('media').'catalog/category/'.$cur_category->getThumbnail();
       ?>

Try this updates.

OTHER TIPS

<?php  $catId = $_category->getId(); ?>
<?php $thumb = Mage::getModel('catalog/category')->load($catId)->getThumbnail();?>
<img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$thumb;?>" >

You need to put this code into catalog/category/view.phtml

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top