Shopify recently removed productVariantUpdate from GQL and i got a replacement productVariantBulkUpdate. Problem is i use this in a bulk mutation and i dont know how to convert the productVariantBulkUpdate into a bulk mutation.
This is the mutation i have so far for me to update the price and compareAtPrice
mutation priceupdate {
productVariantsBulkUpdate(
productId: "gid://shopify/Product/7125238513821"
variants: {compareAtPrice: "49.9", price: "39", id: "gid://shopify/ProductVariant/41289097576605"}
){
userErrors {
field
message
}
}
}
How do i turn this into a bulk mutation? and also what is the jsonl format for me to upload? Let me know if you need more information. I am running it on python3
1 Like
Hi @Jianwei_Lee,
The productVariantBulkUpdate can certainly be run in a Bulk Mutation, specifically with bulkOperationRunMutation.
Here is a Shopify.dev documentation that explains how to run Bulk Mutations in further detail:
First you would need to create a JSONL file containing the data you want to run with multiple productVariantsBulkUpdate mutations.
This section of the documentation describes how to create the JSONL file with examples:
Then you’ll prepare and upload the JSONL file. First creating the parameters used for the upload with the stagedUploadsCreate mutation. Then using the parameters returned from that mutation, you’ll make an HTTP POST Multipart Form request to upload the actual JSONL file to the URL returned from the stagedUploadsCreate mutation.
Once the JSONL file has been uploaded, you’ll create the actual Bulk Mutation Operation by passing the productVariantBulkUpdate mutation you want to run as a string in the input of the bulkOperationRunMutation mutation.
Since Bulk Operations are ran asynchronously you’ll need to be notified when the operation is complete. You can do this either by subscribing to the bulk_operations/finish webhook, or by polling the status of the operation with a currentBulkOperation query.
And finally once the operation is complete the currentBulkOperation response, or querying the BulkOperation ID on the GraphQL node field will provide you with a url string where you can download the results in another JSONL file.
Hi @Jianwei_Lee,
I just wanted to follow up here and see if this helped answer all your questions at this time? If so we can go ahead and close this thread for now, otherwise I’m happy to help further if needed!