- Preparing Environments
- CSV Generation
- CSV Import
- CSV Status Generation
- CSV Preowned Generation
- CSV Import Preowned
- Additional import actions
To prepare the environments before importing, we need to clean up the existing data.
We have 2 cleaning options:
To full cleaning, run all SQL from the folder sql/PTP/*.sql
List of files:
00 - clean data patches.sql- clears the list of data patches that are responsible for reimporting options, this will automatically reimport all the necessary options after cleaning, using thebin/magento setup:updatecommand01 - clean products.sql- cleaning products02 - clean option group.sql- clearing option groups03 - clean complications.sql- clearing complications04 - clean options.sql- clearing options05 - clean ptp.sql- clearing additional tables created to manage options06 - clean log.sql- clearing the synchronization log table
Usually it is only the removal of products, but with full preservation of attribute options.
For partial cleaning, we need to select the files necessary for a specific situation. For example, if we need to clean only products, and save options and all other data, then we need to run queries only from the file: 01 - clean products.sql
The option of cleaning only products will suit us if we want to import products from scratch, but so that we do not have to reimport options.
For TIC we also have 2 options:
These are the same requests, with the addition of an additional request to disable synchronization. After completing all the actions, synchronization must be activated manually.
00 - disable sync.sql- disabling synchronization and clearing flags01 - clean products.sql- cleaning products02 - clean option group.sql- clearing option groups03 - clean complications.sql- clearing complications04 - clean options.sql- clearing options05 - clean ptp.sql- clearing additional tables created to manage options06 - clean log.sql- clearing the synchronization log table
For example, to clean only products, you need to run queries from the following files:
00 - disable sync.sql- disabling synchronization and clearing flags01 - clean products.sql- cleaning products
After performing all the necessary actions, we need to activate synchronization manually.
Generating csv for import based on a file from the client.
CSV files provided by the client contain several header lines - this is an example instruction for mapping.
We need to leave only one row of headers, this row should contain headers for each column.
If the structure of the file provided by the client has not changed, then we need to perform the following actions:
- Remove extra header lines (mapings) from the client file
- Rename the file to
to-process.csv - place the file next to the file
convert.php - execute the
php convert.phpcommand - check the result in the
products_v{version}.csvfile, which should be located next to the fileconvert.php
If the structure of the file provided by the client has changed, then it is necessary to review all columns and make changes to the file convert.php so that the script can work with the new file structure.
To import, select the Products type.
All images are located in the var/import/images/watches folder, so when importing products, we must specify the folder with images as watches.
After importing the products, we need to mark the images from the feed Brand as available for synchronization. This can be done by using a query:
UPDATE `catalog_product_entity_media_gallery_value` SET `share` = 1 WHERE `feed` = 'brand';Since the status is not synchronized between PTP and TIC, it is necessary to import the status manually.
- to do this, run the php command
php status.php - the
to-process.csvfile should be next to thestatus.php - the result will be in the
status_v{version}.csvfile - import to TIC using standard way
To import Preowned, we must also generate a csv compatible with Magento.
To do this, perform the following actions:
- remove extra header lines (mappings) from the client file
- Rename the file to
to-process.csv - place the file next to the file
preowned.php - execute the
php preowned.phpcommand - check the result that should be next to the file
preowned.php:preowned_v{version}.csv- for importing preowned productspreowned_v{version}_qty_assign.csv- to import inventory into pick-up sourcepreowned_v{version}_qty_unassign.csv- to unlink the product from default source
The conversion process may take some time, since this import uses links to images, the script checks beforehand.
Since links are used for images in the file, the import takes a lot of time, and there is no way to complete it through the admin panel.
A CLI tool was developed for importing.
To import, we need to upload the csv to the server and run the command:
php bin/magento catalog:import path/to/file.csvSince this will take time, and in order not to interrupt the execution accidentally, it is better to use hohup:
nohup bin/magento catalog:import path/to/file.csv > ./var/log/nohup_import.log &Next, we need to import inventory, for this we have 2 additional files:
preowned_v{version}_qty_assign.csv- use theStock Sourcestype, andAdd/Updatebehavior.preowned_v{version}_qty_unassign.csv- use theStock Sourcestype, andDeletebehavior.
If there is a need to update some attribute, then we can modify the script and leave only the necessary columns, or we can generate a complete file, and then delete all unnecessary columns and import only the necessary attributes with reference to the SKU.