Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Convert data

Jordan Verasamy edited this page Mar 26, 2019 · 19 revisions

The Basics

Run shopify_transporter and use the convert command to convert your previously extracted object files from the third-party platform format to the Shopify format.

This command has one required parameter:

  1. object: The object you are trying to convert: customer, order, or product.

There is also one optional parameter:

  1. config: The configuration file to be used. Defaults to config.yml.

Sample Usage

The following command converts a JSON file (magento_customers.json) (that contains customer information produced by the extract command) to the equivalent Shopify format, applying the default mapping rules. (See pipeline stages for more details.)

shopify_transporter convert --object=customer magento_customers.json > shopify_customers.csv

In this example, the converted customer objects are saved to shopify_customers.csv. If errors occur during the conversion, they will appear in your terminal.

Convert multiple files

To convert multiple files to Shopify’s format, separate the file names with a space:

shopify_transporter convert --object=customer magento_customers_1.json magento_customers_2.json ...

Record key

The config.yml file allows you to define the object type to convert. An object type needs a record_key, whose value must be unique among the other records in the file. For example, the default record_key for customers is the customer's email address.

platform_type: Magento
object_types:
 customer:
   record_key: email
   ...

When you run shopify_transporter with the convert command, the input files you got from exporting from your platform are read one-by-one, in order. Each object in the input file must have a record_key value. Rows that have the same record_key value are considered to be part of the same object. In our example above, customers are unique and so the record_key is not used to group related records together and is used to discern a single, unique customer from another.

In the case of a record that does run on more than one row (products and orders), the record_key is important.

platform_type: Magento
object_types:
 product:
   record_key: product_id
   ...

For instance, if we had a Magento file containing products, we would use the product_id to associate many products that share a parent product through the record_key and map them to the Shopify equivalent, product variants.

Pipeline stages

We convert input files provided to the convert command through a series of steps called pipeline stages. These stages describe how to construct distinct Shopify objects out of each JSON object found in the input files.

The default pipeline stages that are applied by convert are listed in the config.yml file, and the source code for them is included as part of this gem.

In addition to the pipeline stages provided out-of-the-box, custom, user-defined, pipeline stages can also be defined and applied to the conversion process.

Read more about custom pipeline stages here.