Type
magento2-module
CMS import/export commands for Magento2
magento2-module
MIT
None
None
None
None
None
None
A Magento2 Module providing CMS-related command-line tools.
This module can be installed via composer and the Magento2 command-line tool. For example:
composer require do-it-well/magento2-module-cms-command
./bin/magento module:enable DIW_CmsCommand
./bin/magento setup:upgrade
block_id
page_id
The cms:*:dump
commands dump either a single model, or each of a collection of
models, and directly output the result of $model->getData()
as a JSON object
to STDOUT.
The cms:*:load
commands read a JSON object (or each object from a JSON array
of objects). If a relevant *_id
attribute is set within the JSON object, that
object is loaded; otherwise, an empty model is created. In either case, the
decoded JSON object is passed to $model->setData()
directly, and the model is
saved. ie: if the *_id
field is not set, a new page/block will be created.
As should be obvious, this method of dumping / loading CMS data is very basic, and there are many situations in which these methods would not be appropriate or safe. No guarantees are made. You should perform both dumps and loads only with a complete understanding of the limitations of this implementation.
You can dump a specific page or block as a single json object to STDOUT, by identifier
$ bin/magento cms:page:dump home
{"page_id":"2","title":"My eCommerce Site","page_layout":...
...or by numeric id
$ bin/magento cms:page:dump 2
{"page_id":"2","title":"My eCommerce Site","page_layout":...
You can also dump all pages / blocks, as a json array of json objects, by omitting the id/identifier
$ bin/magento cms:page:dump
[
{"page_id":"1","title":"404 Not Found","page_layout":...},
{"page_id":"2","title":"My eCommerce Site","page_layout":...},
...
The same format can also be used to re-import a dumped page or block
$ bin/magento cms:page:dump home > home.json
... edit home.json ...
$ bin/magento cms:page:load < home.json
...or a list of multiple pages or blocks
$ bin/magento cms:page:dump > pages.json
... edit pages.json ...
$ bin/magento cms:page:load < pages.json
All module code within this repository is licensed under the MIT license. See the MIT-LICENSE.txt file for details.
If you encounter any problems with this module, you may open an issue on GitHub at https://github.com/do-it-well/magento2-module-cms/issues
Premium support, assistance in module installation or configuration, or other development services, can be obtained by contacting Do It Well Limited