php Magento 静态 CMS 块存储在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4932652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:17:53  来源:igfitidea点击:

Where are Magento static CMS blocks stored?

phpmysqlmagento

提问by pm.

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

我无法确定数据库中静态 CMS 块的位置。他们在哪里?

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?

编辑:如果有人发现问题不清楚,我知道如何在 Magento 后端创建静态块。问题是它们存储在 Magento 数据库/文件系统中的什么位置?

回答by clockworkgeek

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.

块存储在数据库表中cms_block。但是,如果要以编程方式创建它们,则无需知道这一点。

$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();

回答by Andre Nickatina

They are in the db table cms_blocklike 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_storeor the block won't appear.

它们cms_block像clockwork geek所说的那样在db表中,但请注意,如果您通过sql(例如使用模块安装脚本)将它们添加到db中,您还需要将新创建的块id和商店id添加到表中cms_block_store否则块不会出现。