Magento Expert Forum - Improve your Magento experience
-
Magento 2: create CMS page programmatically
CMS page is highly important in case of you want to run your Magento 2 website. That is why MageDirect team prepared a tutorial for creation of Customer Management System Page in Magento 2 programmatically. Take a look how to do it here: https://magedirect.co/resources/arti...grammatically/.
View more threads in the same category:
- buy a USA/UK passport online( https://legitcleandocs.com)visa, SNN, id card
- buy registered drivers license online(legitcleandocs.com)passport,IELTS certific
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- buy real passports online(https://legitcleandocs.com)drivers license, visa, id card
- BUY UNDETECTABLE GRADE A+ COUNTERFEIT BANKNOTE(legitcleandocs.com)
- BUY REGISTERED DRIVERS LICENSE ONLINE https://worldpassporte.com/
-
-
Follow the below steps to create CMS page programmatically.
Create UpgradeData.php and define upgrade()
File : app/code/PHPCodez/First/Setup/UpgradeData.php
<?php
namespace Vendor\Module\Setup;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class UpgradeData implements UpgradeDataInterface {
protected $_pageFactory;
public function __construct(\Magento\Cms\Model\PageFactory $pageFactory) {
$this->_pageFactory = $pageFactory;
}
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) {
$setup->startSetup();
if (version_compare($context->getVersion(), '0.1.4') < 0) {
$page = $this->_pageFactory->create();
$page->setTitle('PHPCodez CMS page')
->setIdentifier('phpcodez-cms-page')
->setIsActive(true)
->setPageLayout('1column')
->setStores(array(0))
->setContent('This is a test Page created by PHPCodez. Cheers !!!')
->save();
}
$setup->endSetup();
}
}
Setup the module version
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="PHPCodez_First" setup_version="0.1.4"/>
</config>
Purge cache and deploy static content.
php bin/magento cache:flush
php bin/magento setup:static-content:deploy -f
-
-
Creating CMS Page programmatically
1: Create UpgradeData.php file
2: Insert UpgradeData class
3: Setup the module version
4: Run the upgrade script
-
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks