开发者

magento:generate cms pages dynamically

Hello everybody,

I need to know if CMS pages can be created dynamically, corresponding to each new product created in Magento. OR simply create CMS pages dynamically in magento.

I have done a lot of research on it but could not find any exact content. (I am using Magento 1.5.)

Please help is it possible or not? If not, why? I need to at least know why is it not possible to开发者_Python百科 create CMS pages dynamically in Magento.

Any help would be deeply appreciated. Thanks a lot


Here is the code to create CMS page dynamically/programmatically:-

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$cmsPage = array(
            'title' => 'My CMS Page',
            'identifier' => 'cms-page',
            'content' => 'Sample CMS Page',             
            'is_active' => 1,
            'sort_order' => 0,
            'stores' => array(0),
            'root_template' => 'three_columns'
            );

Mage::getModel('cms/page')->setData($cmsPage)->save();

Note that the line: Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); is only necessary if you are creating CMS page from frontend.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜