Products¶
The Products push creates products in Shopify and updates them, with their options, variants and metafields. It also updates existing variants by their Variant Id, for a price or SKU change without touching the rest of the product, and adds new variants to an existing product.
On a push connector, select Products as the Shopify Import Type. The push sends each product through Shopify's productSet mutation. It updates variants by Variant Id through productVariantsBulkUpdate, and adds new variants beside them through productVariantsBulkCreate.
Every Shopify product has at least one variant. The variant holds the price, SKU and inventory settings. A product without size or colour options has exactly one variant, its main variant.
Records¶
| Record | Under | One for each |
|---|---|---|
| Product | product | |
| Variants | Product | variant of the product |
| Product Metafields | Product | metafield on the product |
| Variant Metafields | Variants | metafield on the variant |
Creating and Updating¶
Product Id decides between creating a product and updating one. Leave it blank to create the product, and IMan writes the new id back. Map the product's id to update it. The id can be numeric or a gid, such as gid://shopify/Product/1234567890. See Update Strategy.
A Product with One Variant¶
Map the Main Variant fields on the Product record, such as Main Variant SKU and Main Variant Price, and leave out Variants records. To update the main variant, map Main Variant Variant Id as well as Product Id.
A product can have Main Variant fields or Variants records, not both. A product with both fails:
The Main Variant fields can't be used on a product that has Variant rows; send the main variant as a Variant row instead.
A Product with Options and Variants¶
Name the product's options with Option 1 Name to Option 3 Name on the Product record, such as Colour and Size. Give each Variants record its options in Option 1 Name and Option 1 Value to Option 3 Name and Option 3 Value, such as Colour with Red and Size with Large. IMan builds the product's option list from the values its variants use.
How the push treats the variants depends on which Variants records carry a Variant Id:
- No Variants record has a Variant Id. The push sets the product's variants to the ones the records list. Shopify keeps the variants whose option values match a record, creates those it does not have and deletes any variant the records leave out. Send every variant the product should keep.
- Every Variants record has a Variant Id. The push updates those variants and nothing else. It leaves the product's other variants and its options as they are.
- Some records have a Variant Id and some do not. The push updates the variants with a Variant Id and adds the others to the product as new variants. It leaves the product's other variants as they are. See Adding Variants to an Existing Product.
When any Variants record has a Variant Id, Product Id is required. The product's own fields go first when the record sets any, and IMan does not send the option names on the Product record.
Shopify deletes the variants you leave out
With no Variant Ids, the product's variants become exactly the ones the records list. To add variants to an existing product, send its existing variants with their Variant Ids beside the new ones, or send every variant the product should keep.
To change only prices or SKUs, read the variants with the Product Variants pull, set the new values in a Map transform, and push them with their Variant Ids and Product Id.
Available Quantity (New Variant Only) and Inventory Location (New Variant Only) set a new variant's opening stock at one location. IMan sends them:
- for each variant of a new product, when Product Id is blank;
- for each Variants record without a Variant Id on a product where other records have one. See Adding Variants to an Existing Product.
IMan sends no stock for a variant with a Variant Id. It sends none either when the push sets an existing product's variants without Variant Ids, not even for the variants the set adds. On that path Shopify would also overwrite the stock of the variants the product already has. Use Inventory Levels v2 to set stock afterwards.
Adding Variants to an Existing Product¶
Send each new variant as a Variants record without a Variant Id, beside at least one of the product's existing variants with its Variant Id, and map Product Id. IMan updates the existing variants, then creates the new ones. It writes each new variant's Variant Id and Inventory Item ID back to its record.
- A new variant can use only the options the product has. It can bring a new value of one of them, such as a new size, and Shopify adds the value to the option. A Variants record that names an option the product does not have fails.
- A new variant must differ from every variant the product has. A record without a Variant Id whose option values match an existing variant fails. Map that variant's Variant Id to update it instead. IMan does not look variants up by their option values.
- Shopify creates a record's new variants together. When it refuses one, it creates none of them, and the record fails.
A Product with Only Its Default Variant¶
A product with no options of its own has one variant, its default variant. Shopify shows it under a Title option with the value Default Title. To give the product options and add variants to it, send the default variant as a Variants record with its Variant Id and its option names and values, beside the new variants. Send it as a Variants record, not through the Main Variant fields.
IMan first gives the product the options on the default variant's record, and the default variant takes that record's values. It keeps its id, SKU and stock. IMan then creates the new variants.
The default variant's record must have its option names and values. Without them, the product fails before IMan sends anything for it:
The product has only its default variant, so it has none of the new variants' options yet: give the default variant's row (the one with its Variant Id) the option names and values it is to take.
When a Step Fails¶
IMan sends a product that adds variants in up to four steps, in this order:
productOptionsCreate, for a product with only its default variant.productSet, when the Product record sets any of the product's own fields.productVariantsBulkUpdate, for the variants with a Variant Id.productVariantsBulkCreate, for the new variants.
When a step fails, IMan sends nothing further for the product and fails the record. The message names the steps IMan has already applied, and names a refused new variant by its position among the product's Variants records:
Variant row 2 could not be created: Option does not exist (Colour). Already applied for this record: productSet, productVariantsBulkUpdate.
A new variant that matches an existing one fails with:
Variant row 2 could not be created: The variant 'L' already exists. To update that variant, map its Variant Id. Already applied for this record: productSet, productVariantsBulkUpdate.
Shopify keeps what IMan has already applied. Correct the record and run it again.
Key Fields¶
| Field | Record | Effect |
|---|---|---|
| Product Id | Product | Blank creates the product. A Shopify product id updates it. Written back after a create |
| Handle | Product | The product's URL handle. Shopify makes one from the title when it is blank |
| Status | Product | ACTIVE, DRAFT or ARCHIVED, in capitals |
| Inventory Management (Is Tracked) | Variants, and Main Variant on Product | True tracks the variant's stock. shopify, the REST value, also means tracked. Anything else means not tracked |
| Option 1 Name to Option 3 Name | Product | The product's option names |
| Main Variant Variant Id | Product | The main variant to update. Written back after a create |
| Variant Id | Variants | Updates that variant through productVariantsBulkUpdate. Blank for a new variant, and written back after the create |
| Option 1 Name to Option 3 Name, Option 1 Value to Option 3 Value | Variants | The variant's options, each name with its value |
| Inventory Item ID | Variants | Written back. Use it with Inventory Levels v2 |
| Synchronous Update | Product | Blank or True waits for Shopify to finish the product. False lets Shopify finish it in the background, and IMan gets no ids back |
| Use Bulk Operations | Product | True sends the run through bulk operations |
The other fields carry the product's and variants' data: title, description, vendor, product type, tags, SEO title, gift card, barcode, prices, cost, weight, tax, shipping and unit pricing.
Metafields¶
A product and each of its variants can carry metafields in two ways. Use whichever suits the source data:
- Metafield slots. Metafield 1 to Metafield 10 on the Product record belong to the product. Main Variant Metafield 1 to 10 belong to its main variant. Metafield 1 to 10 on a Variants record belong to that variant. Each slot has a Namespace, Key, Type and Value.
- Metafields records. A Product Metafields record under the product, or a Variant Metafields record under a variant, holds one metafield each. Use them when the number of metafields varies.
The rules match the Metafields push:
- A slot with no Key is unused. A Metafields record needs a Key.
- A blank Namespace is
custom. - A blank Type uses the metafield's definition.
- A blank Value deletes the metafield. The Value field must therefore be on the transform.
IMan writes the product first, then sends its metafields to the ids Shopify returned. A metafield that Shopify refuses fails its record, and the message says IMan wrote the product itself:
The product was written, but metafield custom.season on gid://shopify/Product/1234567890 failed: ...
The push never sends metafields inside productSet. That would delete every metafield on the product it was not sent, including other apps'. Setting one metafield twice on the same owner fails the record before IMan writes it.
Speed and Bulk Operations¶
The push sends one product at a time. MaxConcurrentRequests in the connection string lets it send several metafield requests at once. Designer runs send one at a time.
With Use Bulk Operations on, IMan sends the run through Shopify bulk operations. Records that change the same Product Id go in successive rounds. Each round first reads the options of the products that add variants. It then sends the steps in the order above, each as an operation of its own: the options of products with only their default variant, the products, the variant updates and the new variants. After the last round, IMan sends the metafields.
A product that fails a step gets nothing further. A product that adds variants fails with the same messages as on a normal run. When Shopify writes any other product's own fields but refuses its variants, the product logs:
Errors¶
Action on Transform Error applies as usual. A product Shopify refuses fails with Shopify's message, and the run goes on or stops as the setting says. A product that fails one of the checks above fails before IMan sends anything for it.
Access Scopes¶
The push needs write_products, and write_inventory for a new variant's opening stock. See Access Scopes.
Shopify Reference¶
productSet, productVariantsBulkUpdate, productVariantsBulkCreate and productOptionsCreate in Shopify's GraphQL Admin API reference.