How to import Produts with Variants from the Relational Database to Shopify
In this tutorial we will show you how to set up the integration between MySQL and Shopify importing Shopify products with variants from MySQL database.
Shopify product variants are stored as an array in the Variants field of the Products table. Let’s imagine, you need to import a list of products, stored in one database table, with their variant stored in another database table, to Shopify. Data about Product Variants in Shopify is an array which is nested into the Variants field of the Products table. To perform such kind of import you need to map the nested items of the Variants field.
For such integrations, Skyvia has Nested Objects feature that allows mapping the nested object properties and nested array items directly, without the need to construct complex JSON values via expressions.
You need to have both Source and Target connections created to be able to set up the Import package and implement this use case.
You can do it in advance or right in the package editor when selecting the Source and Target connections.
For details on how to establish the connection to MySQL and Shopify refer to the detailed manuals.
Creating the Import package
- Create new Import package.
- Edit the package name.
- Select the MySQL connection as a source and Shopify connection as a Target.
Select the Nested Objects checkbox.
- Click Add New on the right to add the import task
Configuring Task Editor Settings
Source Definition tab
- Select the task editor mode in the opened window. Here you can select Simple or Advanced Task Editor modes. Select Simple Mode for our case.
- Select the table to import data from in the Source list. In our case it is the Products table.
- You also can use filters to limit the number of imported records, if needed.
- Select the Target object. In this case this is the Products table.
Select the action you want to execute. We select the Insert operation for our case.
Mapping Definition tab
- Map the needed Product table fields, such as Title, ProductType, and others.
To map the nested Variants field lines you should select the right mapping type:
Use Column mapping if the source field is also an array. In this case source nested fields could be mapped to the target nested fields directly.
Use Source Lookup mapping, if you importing product variants items from the regular table and you want to import its fields into the nested array.
Click Shopify Variants column and select Source Lookup in the source Column drop-down list on the left.
With the Nested Objects checkbox selected, the Variants field provides access to fields of its nested object, which you can easily map.
Select the table which fields you want to map to the nested target fields. In our case the lookup object is Productvariants table. Lookup key is ProductId field.
Now the nested fields become available for mapping. You can map other fields inside the Variants array.
When everything is ready, save the task and you get the package ready to run. Click Create and run it.
You can check the run result on the Monitor tab.
Click on the run and you will see the History details on the right. If you click on the number of successfully processed row, you can see the package log.
As a result we have created a new Product record with product variants as a nested array.