CLI Import Command
designcoil/module-import-command
Provides CLI commands that wrap Magento's native ImportExport pipeline, enabling large catalog imports (products, customers) via the command line without Admin UI timeouts. Supports validation, configurable CSV options, and batch processing.
Build Tests
Code Quality
Tested on Magento 2.4.8-p4
Recent Test History
Each release is tested against the latest Magento version at that time.
Top Contributors
View LeaderboardShare This Module's Status
README
Loaded from GitHubCLI Import for Magento 2
CLI commands that wrap Magento's native ImportExport pipeline - the exact same codepath used by Admin > System > Data Transfer > Import.
Useful for large catalog imports without Admin timeouts. Importing 10k–100k+ products through the Admin UI often results in PHP max execution time exceeded, browser session expiration, Cloudflare timeouts. Running imports via CLI avoids web server limits and is suitable for large catalogs and scheduled batch jobs.
Commands
| Command | Description |
|---|---|
product:import:validate |
Validate a CSV import file and report errors |
product:import:run |
Validate, import, and invalidate indexes |
Requirements
- Magento 2.4.x (Open Source or Commerce)
- PHP 8.2, 8.3, or 8.4
Installation
Via Composer (recommended)
composer require designcoil/module-import-command
bin/magento module:enable DesignCoil_ImportCommand
bin/magento setup:upgrade
bin/magento setup:di:compile
Manual
Copy the module to app/code/DesignCoil/ImportCommand/, then:
bin/magento module:enable DesignCoil_ImportCommand
bin/magento setup:upgrade
bin/magento setup:di:compile
Usage
Validate a CSV file
bin/magento product:import:validate \
--entity=catalog_product \
--file=var/import/products.csv
Output on success:
Validation result: OK
Summary:
Rows processed: 100
Entities processed: 100
Invalid rows: 0
Total errors: 0
Error limit exceeded: No
Output on failure:
Validation result: FAILED
Errors:
Wrong URL/path used for attribute additional_images in row(s): 1, 2
Summary:
Rows processed: 100
Entities processed: 100
Invalid rows: 2
Total errors: 2
Error limit exceeded: No
Run a full import
bin/magento product:import:run \
--entity=catalog_product \
--file=var/import/products.csv \
--behavior=append \
--images-file-dir=var/import/images
Output:
Validating import data...
Validation passed. Importing 100 row(s) in 1 batch(es)...
1/1 batches [============================] 100%
Import completed successfully.
Created: 80
Updated: 20
Deleted: 0
Summary:
Rows processed: 100
Entities processed: 100
Invalid rows: 0
Total errors: 0
Error limit exceeded: No
CLI Options
All options are available on both commands.
Required
| Option | Description |
|---|---|
--entity |
Entity type code: catalog_product, customer, customer_address, etc. |
--file |
Path to CSV file. Absolute or relative to Magento root. |
Import behavior
| Option | Default | Description |
|---|---|---|
--behavior |
append |
Import behavior: append, add_update, replace, delete |
Validation
| Option | Default | Description |
|---|---|---|
--validation-strategy |
validation-stop-on-errors |
validation-stop-on-errors or validation-skip-errors |
--allowed-error-count |
10 |
Maximum number of errors before stopping |
CSV format
| Option | Default | Description |
|---|---|---|
--field-separator |
, |
Column delimiter |
--multiple-value-separator |
, |
Separator for multi-value fields |
--enclosure |
" |
CSV field enclosure character |
--fields-enclosure |
off | Flag. Enables fields enclosed by double-quotes (matches Admin checkbox) |
File & locale
| Option | Default | Description |
|---|---|---|
--images-file-dir |
(none) | Images directory relative to Magento root (e.g. var/import/images) |
--locale |
(none) | Locale code for import (e.g. en_US) |
How it works
- The CSV file is copied into
var/importexport/- the same temp location Magento's admin upload uses. - A native
Magento\ImportExport\Model\Import\Source\Csvadapter is created. Import::validateSource()validates the data and saves it to the database in batches.Import::importSource()reads those batches and performs the actual create/update/delete operations.Import::invalidateIndex()marks related indexers for reindex.
This is identical to clicking Check Data and then Import in the admin panel.
Examples
Product import with semicolon-delimited CSV:
bin/magento product:import:run \
--entity=catalog_product \
--file=/absolute/path/to/products.csv \
--behavior=append \
--field-separator=";" \
--multiple-value-separator="|" \
--images-file-dir=var/import/images \
--fields-enclosure
Customer import, skip errors:
bin/magento product:import:run \
--entity=customer \
--file=var/import/customers.csv \
--behavior=add_update \
--validation-strategy=validation-skip-errors \
--allowed-error-count=50
Validate only (dry run):
bin/magento product:import:validate \
--entity=catalog_product \
--file=var/import/products.csv \
--validation-strategy=validation-skip-errors \
--allowed-error-count=100 \
--images-file-dir=var/import/images
License
This content is fetched directly from the module's GitHub repository. We are not the authors of this content and take no responsibility for its accuracy, completeness, or any consequences arising from its use.