Shopify 库存未通过 Shopify GraphiQL 应用程序更新
我已经检查了 Shopify GraphQL API,并且我尝试过更新 Shopify 上的产品库存,但当我执行 graphql API 时,它显示“
库存数量无法使用变体 API 进行更新
我正在尝试运行的突变:
mutation productVariantsBulkUpdate(
$productId: ID!,
$variants [ProductVariantsBulkInput!]!
) {
productVariantsBulkUpdate(
productId: $productId,
variants: $variants
) {
product {
id
}
productVariants {
id
}
userErrors {
field
message
}
}
}
此请求的变量
{"variants": {"inventoryQuantities": {"availableQuantity": 10,"locationId":"gid://shopify/Location/66027421902" },"id":"gid://shopify/ProductVariant/40747448828110" },"productId": "gid://shopify/Product/6899888488654"}
并且我已使用 批量更新库存,但这不是我需要的,我如何设置(而不是调整)使用库存水平Shopify API?
I have checked the Shopify GraphQL API, and I have tried to update the product inventory on Shopify but when I execute the graphql API it says "
Inventory quantities cannot be updated with variants API
The mutation I am trying to run:
mutation productVariantsBulkUpdate(
$productId: ID!,
$variants [ProductVariantsBulkInput!]!
) {
productVariantsBulkUpdate(
productId: $productId,
variants: $variants
) {
product {
id
}
productVariants {
id
}
userErrors {
field
message
}
}
}
And the variable of this request
{"variants": {"inventoryQuantities": {"availableQuantity": 10,"locationId":"gid://shopify/Location/66027421902" },"id":"gid://shopify/ProductVariant/40747448828110" },"productId": "gid://shopify/Product/6899888488654"}
I have checked with the bulk update inventory but it is not what I need, how do I set (not adjust) the inventory level using the Shopify API?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,这看起来是故意的,目前无法使用 GraphQL API 直接设置库存水平
来自 此 Shopify 文档页面:
好消息是,这可以通过 REST API 实现,并且详细信息在上述同一页面的“REST”选项卡下提供。
我会向 Shopify 请求此功能,因为它在某些不适合调整数量的情况下很有用(例如编写幂等函数)。
Unfortunately, it looks like this is intentional and that there is no way to directly set inventory levels using the GraphQL API at this time
From this Shopify documentation page:
The good news is that this is possible via the REST API, and details are provided on the same page as above, under the "REST" tab.
I will request this feature from Shopify as it is useful in some cases where adjusting quantity is not appropriate (e.g. writing idempotent functions).
我遇到了同样的问题,并使用了
productVariantUpdate()
,您可以将所有变体放入列表中,然后使用此突变对它们进行循环I had the same problem and used
productVariantUpdate()
instead, you can just put all you variants in a list and loop on them using this mutation