Introduction
Starting with version 5.5.1, it has become possibile to import data via the console, which allows to make the import process faster and more stable.
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. 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
--use-workers (-w)
Enable the usage of workers; it makes the process faster. Note that some additional X-Cart configuration is required:
- In
.env
(.env.local
), the settingBACKGROUND_JOBS_ENABLED
must be set totrue
- The following workers must be running:
php bin/console messenger:consume
- no fewer than two, otherwise there will be no noticeable performance improvement.
--trusted-data (-t)
Disable the processing of textual data through HTML Purifier, as it also significantly affects the performance.
--delimiter (-d) [delimeter]
Field delimiter for CSV
--remove-file (-r)
Automatically delete files after import
import.sh
An additional script is provided for importing multiple files at once
./bin/import.sh [options]
Options
-p [directory]
Path to the directory containing the files for import
-w
Use workers
-t
Disable the processing of textual data through HTML Purifier, as it also significantly affects the performance.
-d [delimeter]
Field delimiter for CSV
-r
Automatically delete files after import