我在Where are Magento static CMS blocks stored?上看到了以下关于编程使用PHP在Magento中生成cms/块的回复。
我将代码更改为以下代码
$newBlock = Mage::getModel('cms/page')
->setTitle('Test CMS Page Title')
->setContent('Hello I\'m a new cms page.')
->setIdentifier('this-is-the-page-url')
->setIsActive(true)
->save();
..。而且它是有效的。我看到一个新的页面显示在后端的CMS页面区域。
我需要添加到这是设置CMS/页面中的其他字段的内容的能力。即:
字段。这些字段当前为空。到目前为止,我还没有弄清楚这一部分。
谢谢,
发布于 2012-02-17 15:44:39
这就是了:
$cmsPageData = array(
'title' => 'Test CMS Page Title',
'root_template' => 'one_column',
'meta_keywords' => 'meta,keywords',
'meta_description' => 'meta description',
'identifier' => 'this-is-the-page-url',
'content_heading' => 'content heading',
'stores' => array(0),//available for all store views
'content' => "Hello I'm a new cms page."
);
Mage::getModel('cms/page')->setData($cmsPageData)->save();
数组的键是cms_page
表的字段的名称(检查db)。为了知道这个值,我手动创建了我想要的cms页面,然后在db中查看这个条目的值。
https://stackoverflow.com/questions/9323780
复制相似问题