Magento 1.9 – Update CMS Static Block Content Programmatically

magento-1.9static-block

I have created one CMS static block.

I want to know that can I change its content by code (programmatically).

Is there any way to do it?

Best Answer

Use this

Load by block id:

Mage::getModel('cms/block')->load($id)
  ->setData('content', 'SET CONTENT HERE')
  ->save();

Load By identifier:

Mage::getModel('cms/block')
  ->getCollection()
  ->addFieldToFilter('identifier', 'block_identifier')
  ->load()
  ->setData('content', 'Example content')
  ->save();
Related Topic