Created
May 22, 2015 14:38
-
-
Save jklance/e862564ef4a9e427dd7b to your computer and use it in GitHub Desktop.
Magento - Create a CMS block in an upgrade script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$content = 'BLOCK CONTENT HERE'; | |
//if you want one block for each store view, get the store collection | |
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('store_id', array('gt'=>0))->getAllIds(); | |
//if you want one general block for all the store viwes, uncomment the line below | |
//$stores = array(0); | |
foreach ($stores as $store){ | |
$block = Mage::getModel('cms/block'); | |
$block->setTitle('Block title here'); | |
$block->setIdentifier('block_identifier_here'); | |
$block->setStores(array($store)); | |
$block->setIsActive(1); | |
$block->setContent($content); | |
$block->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment