Friday, July 26, 2013

Magento :: get static block content mapped with category


>> You can display a static block in a category page by Managing the category from admin.



     But if you want the block in a custom page for that category. You use the following code:

         // load the category
        $_category = Mage::getModel('catalog/category')->load($categoryId);
       
        // Fetching the block data
        $html = $this->getLayout()->createBlock('cms/block')
                    ->setBlockId($_category->getLandingPage())
                    ->toHtml();
                   
        echo $html;