Magento: Get Category description from block
I was facing issue for getting category description from cms block. After researching on google I found the solution for it. You just need to add this in the home page content:
{{block type="core/template" template="catalog/category/description.phtml" category_id="213"}}
Now create the file app/design/frontend/{interface}/{theme}/template/catalog/category/description.phtml
with the following content:
<?php $categoryId = $this->getCategoryId();?>
<?php $category = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($categoryId);?>
<?php if ($category->getId() && $category->getIsActive() && $_description = $category->getDescription()) : ?>
<?php echo $this->helper('catalog/output')->categoryAttribute($category, $_description, 'description')?>
<?php endif;?>
Note: This code will work only on product page because we are getting the category id from the current page which is done by writing the following code:
$categoryId = $this->getCategoryId();
First get the category id of the current product page and load category model. Now you can get the category description.
All done!
Thanks for reading the blog.
1 Comment(s)