1

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';
   ?>

2 Answers 2

1
     <?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.

1
<?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

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.