我看到了下面这个帖子的回复Magento 静态 CMS 块存储在哪里? https://stackoverflow.com/questions/4932652/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/页面中其他字段的内容。即:
字段。这些字段目前为空。到目前为止我还没能弄清楚这部分。
Thanks,
干得好:
$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
表(检查数据库)。为了了解该值,我手动创建所需的 cms 页面,然后在数据库中查看此条目的值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)