MageDirect

Magento 2: create CMS page programmatically

We can create CMS pages in Magento 2 using setup scripts. So, to do this, follow the next steps:

Create Setup/UpgradeData.php

Create Setup/UpgradeData.php file inside your module (how to create a module you can read here) with the next code:

Change version

Change version of your module to 0.1.1:

Run the database upgrade script

Run the database upgrade script from the root directory of your Magento 2 store:

Navigate to Content > Pages

Navigate to Content > Pages in the admin panel and check the result:

 

content pages

Was this article helpful?
Dislike 0
Views: 352
Lilya Gogoleva

Lilya GogolevaMagento Developer

Rate us
Please wait...
Bottom
Top