Console import
Introduction
Starting with version 5.5.1, it has become possible to import data via the console, which allows to make the import process faster and more stable.
By default, the import runs asynchronously via the message bus and completes in the background. Use the --interactive (-i) option to monitor progress directly in the console.
Basic usage
./bin/console utils:import path_to_file.csv
Arguments
As an argument, you need to specify the path to the data file; both CSV and jsonl formats can be used. The latter format is used for the internal representation of import data.
It is also possible to specify the directory path, in which case all the files from the directory will be imported. When a
directory is provided, files are automatically sorted in the recommended import order: categories, attributes, products,
product-attributes, users, orders. However, you should take into account the specifics of PHP operation: long processing
times can lead to memory leaks and performance regression, so it is better to import files one by one. To facilitate this
process, the script import.sh is provided.
Options
--interactive (-i)
Interactive mode. When this option is set, the console displays a progress bar, messages and errors during the import. Without this option, the import starts in the background and the command exits immediately with the message "Import will be continued in background mode."
--trusted-data (-t)
Disable the processing of textual data through HTML Purifier, as it also significantly affects the performance.
--delimiter (-d) [delimiter]
Field delimiter for CSV. If not specified, the value from the store configuration (Units → csv_delim) is used,
defaulting to ,.
--update-mode (-u)
Update existing items, but skip new items.
--remove-file (-r)
Automatically delete files after import.
--skip-verification
Skip the verification step. Use this when you are certain the data is accurate and straightforward, such as importing qty/price only. This option has no short form.
--skip-charset-check
Skip the check if the input CSV file is UTF-8 encoded. This option has no short form.
--create-new-vehicles (-c)
This option requires the QSL-Make addon to be installed and enabled.
Whether to create new vehicles when importing product fitments. When this option is set, any vehicles referenced in the import data that do not yet exist in the store will be created automatically.
--template [name]
This option requires the XC-ImportTemplates addon to be installed and enabled.
Import template name. The template must already exist in the store. When a template is specified, additional file formats supported by the template (beyond standard CSV and jsonl) are also accepted.
Example:
./bin/console utils:import --template=MyTemplate path_to_file.csv
--brand [name]
This option requires both the XC-ImportTemplates and QSL-ShopByBrand addons to be installed and enabled.
Brand name for import template. The brand must already exist in the store. When specified, the import associates imported products with the given brand.
Example:
./bin/console utils:import --template=MyTemplate --brand=MyBrand path_to_file.csv
import.sh
An additional shell script is provided for importing multiple files from a directory at once. It iterates over all .csv
and .jsonl files in the specified directory and imports them one by one, which helps avoid memory issues associated with
importing many files in a single process.
./bin/import.sh [options]
Options
-p [directory]
Path to the directory containing the files for import.
-i
Interactive mode (show progress bar, messages and errors in console).
-t
Disable the processing of textual data through HTML Purifier.
-d [delimiter]
Field delimiter for CSV.
-u
Update existing items, but skip new items.
-r
Automatically delete files after import.
-s or -sv
Skip the verification step. Use this when you are certain the data is accurate and straightforward, such as importing qty/price only.
-scc
Skip the check if the input CSV file is UTF-8 encoded.
-c
This option requires the QSL-Make addon to be installed and enabled.
Whether to create new vehicles when importing product fitments.
-tpl [name]
This option requires the XC-ImportTemplates addon to be installed and enabled.
Import template name. Example: -tpl MyTemplate
-b [name]
This option requires both the XC-ImportTemplates and QSL-ShopByBrand addons to be installed and enabled.
Brand name for import template. Example: -b MyBrand
-h
Print help and exit.