Search code examples
magentomagento-1.8

How to set store id to cms block output


I am using below code to display static block content but it display only first store block every time.I am load this cms block on admin side. I have two block with same identifier but assign it to diffrent store so i would like to display it store wise.

Here is code i m using but it didn't help.

Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('pdf_page_of')->setStoreId($storeId)->toHtml()

Solution

  • Try this

    /* set required store */
        Mage::app()->setCurrentStore($storeId);
                $addresBlock =  Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('pdfaddress')->toHtml();
        Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    /* reset admin store after wind up our purpose.*/