This module provides fast, repeatable import and export for Magento CMS Pages, CMS Blocks, and Email Templates.
Key features:
- Import via CLI (immediate and recurring) or Magento Admin Import (CSV only)
- Export via CLI or directly from Admin grids
- Multiple data formats: CSV (default), JSON, XML
- Overwrite and merge options for flexible updates
- CMS Pages
- CMS Blocks
- Email Templates
- CLI — Immediate
- Run a command with a path to a file. The import happens right away.
- Supports CSV, JSON, XML.
- CLI — Recurring
- Adds a new file named
import.jsoninto Magento's import directory (var/import/csv). - The file contains a list of filenames to be imported on the next
bin/magento setup:upgrade. - Useful for committing import definitions into source control and applying them during deployments.
- Magento Admin — Native Import (CSV only)
- Go to System > Data Transfer > Import.
- Select the appropriate entity and upload a CSV file.
- Recommended when you want a UI-driven import and only need CSV.
- CLI
- Admin grids (Pages, Blocks, Email Templates) provide Export actions for CSV, JSON, XML, enabling quick one-off exports without CLI access.
Supported formats:
- CSV (default)
- JSON
- XML
You can change the default format or add processors via Magento's Dependency Injection (see ContentProcessorPool in etc/di.xml).
bin/magento cms:export:page <identifier> [-m|--merge] [--format=<format>]bin/magento cms:export:block <identifier> [-m|--merge] [--format=<format>]bin/magento cms:export:email <identifier> [-m|--merge] [--format=<format>]
Options:
-m|--merge— when exporting multiple entities sharing the same identifier across scopes, merges records into a single file (where applicable).--format— one ofcsv,json,xml(default iscsv).
bin/magento cms:import:page [file_name] [-o|--overwrite] [-r|--recurring]bin/magento cms:import:block [file_name] [-o|--overwrite] [-r|--recurring]bin/magento cms:import:email [file_name] [-o|--overwrite] [-r|--recurring]
Options:
-o|--overwrite— overwrite existing entities when identifiers already exist-r|--recurring— schedule import by appending entries tovar/import/import.jsonand process on the nextsetup:upgrade
Note:
- The file_name can be an absolute path, or a path relative to Magento’s import directory:
var/import/cms/<entity_type>. For example,var/import/cms/page/homepage.csv. When a relative name is provided, the command looks for the file under that folder.
Export a CMS page to JSON:
bin/magento cms:export:page homepage --format=json
Export an email template (merge mode) to XML:
bin/magento cms:export:email newsletter_subscription --merge --format=xml
Immediate import of CMS blocks from CSV and overwrite existing:
bin/magento cms:import:block /var/www/magento/var/import/blocks.csv --overwrite
Schedule a recurring import for email templates:
bin/magento cms:import:email email_templates.json --recurring
bin/magento setup:upgrade
- Add a repository to composer.json:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/ashilkov/module-cms-import-export.git"
}
]
- Require the package:
composer require magecraft/module-cms-import-export
- Enable and upgrade:
bin/magento module:enable MageCraft_CmsImportExport
bin/magento setup:upgrade
- Import directory is Magento’s
var/import. Ensure files are readable by the web/CLI user. - When using recurring import, maintain
var/import/cms/import.jsonin VCS to make deployments reproducible. - CSV is the most portable format (supports Admin Import and grid exports). JSON/XML are recommended for richer structure and diffs in code review.
- If you customize formats or processors, use DI configuration (
etc/di.xml) to adjustContentProcessorPool.
- Found a bug or have a feature request? Please open an issue on GitHub: https://github.com/ashilkov/module-cms-import-export/issues
- Pull requests are welcome. Please describe the change and include tests or reproduction steps when possible.
- Andrei Shilkov — aishilkov94@gmail.com
- GitHub: https://github.com/ashilkov