Usage
As of version To avoid complex adjustments of the configuration, version |
After installation, the importer is ready-to-run.
When you’re in the root of your Magento 2 installation, you do not need to specify the configuration for the Workflow Engine.
The importer parses the installation’s configuration under app/etc/env.php
and loads the Magento Edition/Version as well as the
database configuration.
By default, the importer searches for CSV files in the directory var/importexport
.
The files must have the prefix product-import
, followed by a date/timestamp like 20180403-190920
, a incremental number
like 01
and the file suffix .csv
.
Assuming, your CSV file var/importexport/product-import_20180403-190920_01.csv
is ready to be imported and you’re using the PHAR,
you can start the importer with
bin/import-cli-simple.phar import:create:ok-file && bin/import-cli-simple.phar import:products
The first command creates the mandatory .OK
file that signals, that all import artifacts are on-place and the second command finally
starts the import with the add-update operation on your Magento 2 installation.
The import commands support an argument as well as several options.
Commands
Besides the import commands, several other more or fewer helper commands are available. The following commands for importing the entities are accessible:
Argument | Description | Format |
---|---|---|
import:categories |
Starts importing categories |
|
import:customers |
Starts importing customers |
|
import:customers:address |
Starts importing customer addresses, expects that the customers are available |
|
import:attributes:set |
Starts importing attribute sets and their groups |
|
import:attributes |
Starts importing attributes, expects that the referenced attribute sets + groups are available |
|
import:products |
Starts the product import, expects that the referenced attributes, and the attribute sets and groups, are available |
|
import:products:inventory |
Starts importing product inventory, expects that the products are available |
|
import:products:inventory:msi |
Starts importing product MSI inventory, expects that the products are available |
|
import:products:price |
Starts importing product prices, expects that the products are available |
|
import:products:price:tier |
Starts importing product tier prices, expects that the products are available |
|
import:products:url |
Starts importing product URLs, expects that the products are available |
By default, if no other source directory has been configured, either as command-line option or in the configuration file, all
commands are searching for the CSV files and the matching OK file in the var/importexport
directory of your Magento installation.
Shortcuts
In contrast to the Magento 2 standard import functionality, up from version 3.8.0, Pacemaker Community Edition (CE) will provide two additional import shortcuts (formerly operations):
Shortcut | Description |
---|---|
validate |
Performs an explicit validation of the data in the respective CSV file (available for all entities) |
convert |
Extracts the attributes or categories from given CSV files with products (available for attributes and categories) |
add-update |
New product data is added to the existing product data for the existing entries in the database. All fields except SKU can be updated. New tax classes that are specified in the import data are created automatically. New SKUs that are specified in the import file are created automatically. |
replace |
The existing product data is replaced with new data. If an SKU in the import data matches the SKU of an existing entity, all fields, including the SKU are deleted, and a new record is created using the CSV data. An error occurs if the CSV file references an SKU that does not exist in the database. |
delete |
Any entities in the import data that already exist in the database are deleted from the database. Delete ignores all columns in the import data, except for SKU. You can disregard all other attributes in the data. An error occurs if the CSV file references an SKU that does not exist in the database. |
Exercise caution when replacing data because the existing product data will be completely cleared, and all references in the system will be lost. |
Options
The following configuration options are available:
Option | Description | Default value |
---|---|---|
--serial |
Specify the unique identifier of this import process which will also be the name of the temporary import directory |
Some UUID |
--configuration |
Specify the pathname to the configuration file to use |
n/a |
--custom-configuration-dir |
Specify the path to the custom configuration directory containing snippets to override the default values with |
n/a |
--pid-filename |
The explicit PID filename to use |
|
--system-name |
The system name to be used (will added to the mail subject, if mails are configured) |
The hostname |
--installation-dir |
The Magento installation directory to which the files has to be imported |
The actual working directory |
--source-dir |
The directory that has to be watched for new files |
n/a |
--target-dir |
The target directory with the files that has been imported |
n/a |
--archive-dir |
The directory with the archived files that has been imported |
n/a |
--archive-artefacts |
The flag to activate the artefact archiving functionality |
|
--clear-artefacts |
The flag whether or not the import artefacts have to be cleared |
|
--magento-edition |
The Magento edition to be used, either one of CE or EE |
n/a |
--magento-version |
The Magento version to be used, e.g. 2.1.2 |
n/a |
--use-db-id |
The ID of the database to use, if not specified, the database with the default flag will be used |
n/a |
--db-pdo-dsn |
The DSN used to connect to the Magento database where the data has to be imported, e.g. |
n/a |
--db-username |
The username used to connect to the Magento database |
n/a |
--db-password |
The password used to connect to the Magento database |
n/a |
--db-table-prefix |
The table prefix used by the Magento database |
|
--debug-mode |
The flag to activate the debug mode |
|
--log-level |
The log level to use (see Monolog documentation for further information) |
|
--single-transaction |
The flag to wrap the import process into a single transaction |
|
--params |
A JSON encoded string that’ll be merged with the parameter from the configuration file (has to be in the same format) |
n/a |
--params-file |
The path to a file with the JSON encoded parameter that will be merged with the parameter from the configuration file (has to be in the same format) |
n/a |
--cache-enabled |
Whether or not the cache functionality for cache with the type |
|
--move-files-prefix |
The prefix of the files that should be imported and moved to the temporary directory of the import |
Defaults to the prefix of the first plugin subject |
Besides the configuration
option, all options can and should be defined in the configuration file.
The command-line options should only be used to override these values in some circumstances.
If the If the |