2

I need display category-block below product page in template file .phtml But this code not work. Can you help me?

$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$html = $this->getLayout()->createBlock('cms/block')
                    ->setBlockId($this->getCurrentCategory()->getLandingPage())
                    ->toHtml();


        if (!$this->getData('cms_block_html')) {
            $html = $this->getLayout()->createBlock('cms/block')
                ->setBlockId($this->getCurrentCategory()->getLandingPage())
                ->toHtml();
             $this->setData('cms_block_html', $html);
        }
         return $this->getData('cms_block_html');
1

Hi try this on phtml file

if(Mage::registry('current_category')){
if(Mage::registry('current_category')->getId()>0){
 echo $this->getLayout()->createBlock('cms/block')
                ->setBlockId(Mage::registry('current_category')->getLandingPage())
                ->toHtml();
}

}

but is depends on Mage::registry('current_category'). Magento is set this registry variable when getLastVisitedCategoryId() in catalog session or magento product have

category id in original routering url

Check this at Mage_Catalog_Helper_Product function of function initProduct

  • It's work good but like quote you depends on Mage::registry('current_category'). – Lutty Oct 3 '14 at 7:51
  • It's work good but like quote you depends on Mage::registry('current_category'). I need display block indipendently to current_category but for membership to category. – Lutty Oct 3 '14 at 7:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.