Metafields¶
The Metafields push sets and deletes metafields on products, variants and customers, and on any other Shopify record that takes metafields, such as an order or a company. One record is one metafield.
On a push connector, select Metafields as the Shopify Import Type. The push sends the records 25 to a request through Shopify's metafieldsSet mutation, and one request can mix owners. Shopify creates the metafield, or updates it when the owner already has one with that namespace and key.
The Products and Customers pushes can also set metafields on the records they write.
Fields¶
| Field | Rule |
|---|---|
| Owner Id | Required. The record the metafield belongs to, as a numeric id or a gid. A gid can name any owner Shopify supports, such as gid://shopify/Order/1234567890 |
| Owner Type | Product, Variant or Customer. Required with a numeric Owner Id. Not used with a gid |
| Namespace | Blank is custom |
| Key | Required |
| Type | The metafield type, such as single_line_text_field or number_integer. Blank uses the metafield's definition, and Shopify refuses the record when there is none |
| Value | The value to set. A blank Value deletes the metafield, and deleting one that does not exist is not an error. The Value field must be on the transform |
| Metafield Id | Written back with the metafield's id. Map it only when you need it: asking Shopify for ids costs more of the store's API allowance |
| Use Bulk Operations | True sends the run through bulk operations |
Owner, namespace and key identify a metafield. Two records for the same metafield never share a request. Shopify applies them in the order they came, and the last one wins.
Errors¶
Shopify writes all of a request or none of it. When Shopify refuses some records, those records fail with Shopify's message, and IMan sends the rest of the request again. An error Shopify does not pin to a record fails every record in the request.
A record's result can arrive after IMan has moved on to later records. IMan still logs a failure against the right record. When the transform aborts on error, the run stops at the failure. Shopify may already have written records in other requests.
Shopify caps a json metafield's value at 128 KB, and refuses a larger one.
Speed and Bulk Operations¶
MaxConcurrentRequests in the connection string lets the push send several requests at once. Designer runs send one at a time.
With Use Bulk Operations on, IMan sends the sets as one metafieldsSet bulk operation, 25 metafields to a line, and the deletes as a metafieldsDelete operation of their own. Shopify refuses a line's bad metafields, and IMan sends the rest of the line again in a follow-up operation. Records that write one metafield twice go in later operations. The last one still wins. See Bulk Operations.
Access Scopes¶
The push needs the write scope of each owner: write_products for products and variants, write_customers for customers, and so on. See Access Scopes.
Shopify Reference¶
metafieldsSet and metafieldsDelete in Shopify's GraphQL Admin API reference.