Development discussions around Shopify APIs
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 |
---|---|
46 | |
16 | |
9 | |
9 | |
7 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023