Created
July 9, 2015 12:39
-
-
Save markshust/8eddf4329397c4e7978c to your computer and use it in GitHub Desktop.
update magento static block programmatically through upgrade scripts
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
<?php | |
/* @var $installer Mage_Core_Model_Resource_Setup */ | |
$installer = $this; | |
$installer->startSetup(); | |
$connection = $installer->getConnection(); | |
$identifier = 'id-goes-here'; | |
$title = 'Title Goes Here'; | |
$contentCmsBlock = <<<EOT | |
<div id="$identifier"> | |
<p>Put your content here.</p> | |
</div> | |
EOT; | |
$cmsBlock = Mage::getModel('cms/block')->load($identifier); | |
if ($cmsBlock->isObjectNew()) { | |
$cmsBlock->setTitle($title) | |
->setContent($contentCmsBlock) | |
->setIdentifier($identifier) | |
->setStores(0) | |
->setIsActive(true); | |
} else { | |
$cmsBlock->setTitle($title) | |
->setContent($contentCmsBlock) | |
->setStores(0) | |
->setIsActive(true); | |
} | |
$cmsBlock->save(); | |
$installer->endSetup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
setStores() must get an array as a parameter, or use setStoreId() to give only a unique Id.