Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Magento 1.9.2.1: How to get category description on product page from CMS block

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 2.11k
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: