Tuesday, January 21, 2014

Magento : Get thumbnail in navigation


First create your custom module the follow as
1. Override following file app/code/core/Mage/Catalog/Block/Navigation.php
and a function
public function getThumbnailUrl($category)
{
  return Mage::getModel('catalog/category')->load($category->getId())->getThumbnailUrl();
}

2. Then override following file app/code/core/Mage/Catalog/Model/Category.php
and add a function
public function getThumbnailUrl()
{
  $url = false;
  if ($image = $this->getThumbnail()) {
      $url = Mage::getBaseUrl('media').'catalog/category/'.$image;
  }
  return $url;
}

1 comment: