Hello can you show me an example on how can we create products, with variants, with the new product model api 2024-04 using bulkOperationRunMutation ?
Hello @Antonio84 ,
The Bulk mutation operation requires multiple steps. Here is the actual run query you should use. The steps to upload the JSONL files are well documented in Shopify Dev.
mutation bulkOperationRunMutation(
$mutation: String!
$stagedUploadPath: String!
) {
bulkOperationRunMutation(
mutation: $mutation
stagedUploadPath: $stagedUploadPath
) {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
The variables I use for that query are:
{
"mutation": "mutation productSet($productSet: ProductSetInput!, $synchronous: Boolean!) { productSet(synchronous: $synchronous, input: $productSet) { product { id createdAt updatedAt handle variants(first: 10) { nodes { sku createdAt updatedAt } } } userErrors { code field message } } }",
"stagedUploadPath": "tmp/72607465784/bulk/b68e43f7-719d-4e96-9735-ced94128389c/product-set"
}
The mutation variable will execute the mutation using the data in the JSONL file uploaded. You can change the values in this variable if you need the result to have additional data. This is just an example.
The stagedUploadPath variable is the “key” value returned by Shopify in the stagedUploadsCreate mutation response that you use during the upload process for the JSONL file.
Adearriba, thank you for your response.
I noticed that ProducSet mutation is not able to upload images like the previous ProductCreate or ProductUpdate mutation, do you confirm that?