Magento Programmatically create a cms page

Posted by Damodar Bashyal on May 10, 2013

 

You can easily create a cms page in magento programmatically. Useful when you need to upload a bunch of pages from csv file. Here I haven't created a csv parser but just a simple code to save a cms page.

My file path: /magento/cms-page.php

<?php
include_once 'app/Mage.php';
umask(0);
Mage::app("default");

error_reporting(E_ALL);

//Create Static Block
$cmsPage = array(
                'title' => 'My CMS page',
                'identifier' => 'my-cms-page',
                'content' => 'Lorem ipsum dolor sit, amen hte gulocse',
                'is_active' => 1,
                'sort_order' => 0,
                'root_template' => 'three_columns'
                'stores' => array(Mage_Core_Model_App::ADMIN_STORE_ID)
                );

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

Hopefully it works for you too!!!

 
not published on website


QR Code: Magento Programmatically create a cms page