Development discussions around Shopify APIs
Return management just got easier! We’ve launched Customer Self-Serve Returns to all Shopify merchants. Click here to learn more!
Hi i need to update the price and inventory of the variants once a day and i saw a thread saying i can use productvariantupdate with bulk mutation. I created the bulk mutation below.
mutation {
bulkOperationRunMutation(mutation: "mutation call($input: ProductVariantInput!) {productVariantUpdate(input: $input) {
productVariant { id price inventoryQuantity } userErrors { field message }
}
}", stagedUploadPath: "tmp/58782580893/bulk/0de283d9-3181-4bd8-9a46-******863adb/shopify_uploads") {
bulkOperation {
createdAt
completedAt
errorCode
id
status
}
userErrors {
field
message
}
}
}
I uploaded these variable to the server
{"input":{"id": "gid://shopify/ProductVariant/40678598934685", "price": 55.9, "inventoryQuantity": 23.0}}
{"input":{"id": "gid://shopify/ProductVariant/40678600245405", "price": 69.9, "inventoryQuantity": 15.0}}
When i run the mutation i get the error that inventoryQuantity field does not exist
{"data":{"bulkOperationRunMutation":{"bulkOperation":null,"userErrors":[{"field":null,"message":"Invalid Bulk Mutation Field - Variable $input of type ProductVariantInput! was provided invalid value for inventoryQuantity (Field is not defined on ProductVariantInput)"}]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}
I want/very much prefer to update the price and inventory in a single mutation. Any help is appreciated thank you.
Solved! Go to the solution
This is an accepted solution.
Hey @JJasperr
Yes, that's right - productVariantUpdate is available to be run as part of a bulkOperationRunMutation. InventoryQuantity does not exist on the productVariantInput, although InventoryQuantities does.
However unfortunately, Inventory Quantities is a create only field(docs) and so it wouldn't work with productVariantUpdate as part of the bulk mutation.
To update the inventory quantities, after creation, it is looking like you would need to use inventoryBulkAdjustQuantityAtLocation mutation - there are some docs here. Hope that helps!
This is an accepted solution.
Hey @JJasperr
Yes, that's right - productVariantUpdate is available to be run as part of a bulkOperationRunMutation. InventoryQuantity does not exist on the productVariantInput, although InventoryQuantities does.
However unfortunately, Inventory Quantities is a create only field(docs) and so it wouldn't work with productVariantUpdate as part of the bulk mutation.
To update the inventory quantities, after creation, it is looking like you would need to use inventoryBulkAdjustQuantityAtLocation mutation - there are some docs here. Hope that helps!
User | RANK |
---|---|
16 | |
7 | |
6 | |
6 | |
5 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022