7

I cannot the location of static CMS blocks in the database. Where are they?

The reason I need to know this is that when I move the database and my theme files from my local install to my online dev-install, the block does not update, and I need to re-create them for each installation.

Follow-up question would be, how do I create them programmatically?

EDIT: If anyone finds the question unclear I know how to make a static block in the Magento backend. The question is where are they stored in the Magento db/filesystem?

Joe Mastey
  • 26,809
  • 13
  • 80
  • 104
pm.
  • 225
  • 1
  • 4
  • 14

2 Answers2

20

Blocks are stored in the database table cms_block. But you don't need to know that if you are going to create them programmatically.

$newBlock = Mage::getModel('cms/block')
          ->setTitle('This is the title')
          ->setContent('This is the content')
          ->setIdentifier('an-identifier')
          ->setIsActive(true)
          ->setStores(array(1)) // see Sergy's comment
          ->save();
clockworkgeek
  • 37,650
  • 9
  • 89
  • 127
  • 5
    new created block won't be displayed if block is not assigned to any store. Add "->setStores(array(1))" before save call where 1 is default store_id. So block will appear on frontend – Sergey Jun 26 '12 at 11:58
7

They are in the db table cms_block like clockwork geek has said, but be aware that if you add them into the db through sql (using a module install script for example) you also need to add the newly created blocks id and the store id to table cms_block_store or the block won't appear.

hakre
  • 193,403
  • 52
  • 435
  • 836