且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式在Magento中创建CMS / Page

更新时间:2023-11-30 13:38:28



here you go:

$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 table(检查db)。并且要知道该值,我手动创建我想要的cms页面,然后在db中查看此条目的值。

The keys of the array are the name of the fields of the cms_page table (check the db). And to know the value, I manually create the cms page I want and then see the value for this entry in the db.