Skip to content

sethIam1/ptma_import_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

PTP and TIC Import Scripts


Table of Contents


Preparing Environments

To prepare the environments before importing, we need to clean up the existing data.

PTP

We have 2 cleaning options:

Full - deletes all options and all data related to products.

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 the bin/magento setup:update command
  • 01 - clean products.sql - cleaning products
  • 02 - clean option group.sql - clearing option groups
  • 03 - clean complications.sql - clearing complications
  • 04 - clean options.sql - clearing options
  • 05 - clean ptp.sql - clearing additional tables created to manage options
  • 06 - clean log.sql - clearing the synchronization log table

Partial - allows to delete only the necessary part of the data

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.

TIC

For TIC we also have 2 options:

Full

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.

sql/TIC/*.sql:

  • 00 - disable sync.sql - disabling synchronization and clearing flags
  • 01 - clean products.sql - cleaning products
  • 02 - clean option group.sql - clearing option groups
  • 03 - clean complications.sql - clearing complications
  • 04 - clean options.sql - clearing options
  • 05 - clean ptp.sql - clearing additional tables created to manage options
  • 06 - clean log.sql - clearing the synchronization log table

Partial

For example, to clean only products, you need to run queries from the following files:

  • 00 - disable sync.sql - disabling synchronization and clearing flags
  • 01 - clean products.sql - cleaning products

After performing all the necessary actions, we need to activate synchronization manually.


CSV generation for importing products to PTP

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:

  1. Remove extra header lines (mapings) from the client file
  2. Rename the file to to-process.csv
  3. place the file next to the file convert.php
  4. execute the php convert.php command
  5. check the result in the products_v{version}.csv file, which should be located next to the file convert.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.


CSV Import

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';

CSV generation for importing Statuses to TIC

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.csv file should be next to the status.php
  • the result will be in the status_v{version}.csv file
  • import to TIC using standard way

CSV generation for importing Preowned products to TIC

To import Preowned, we must also generate a csv compatible with Magento.

To do this, perform the following actions:

  1. remove extra header lines (mappings) from the client file
  2. Rename the file to to-process.csv
  3. place the file next to the file preowned.php
  4. execute the php preowned.php command
  5. check the result that should be next to the file preowned.php:
    • preowned_v{version}.csv - for importing preowned products
    • preowned_v{version}_qty_assign.csv - to import inventory into pick-up source
    • preowned_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.


CSV Import Preowned

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.csv

Since 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 the Stock Sources type, and Add/Update behavior.
  • preowned_v{version}_qty_unassign.csv - use the Stock Sources type, and Delete behavior.

Additional import actions

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.

About

Mass Import Product Scripts for PTMA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages