我检查了共享GraphQL API,并试图更新Shopify上的产品库存,但是当我执行graphql时,它说:“
库存数量不能用变体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设置(而不是调整)库存水平?
发布于 2022-05-08 19:28:34
不幸的是,这看起来是故意的,而且目前无法使用GraphQL API直接设置库存水平。
不存在直接使用GraphQL管理API设置级别的突变。使用adjustInventoryLevelQuantity突变来调整库存水平。
好消息是,这可以通过REST实现,并且在上面的"REST“选项卡下面的相同页面上提供了详细信息。
我将要求Shopify提供这个特性,因为在某些情况下,调整数量是不合适的(例如编写幂等函数),这是很有用的。
发布于 2022-07-30 14:22:38
我也有同样的问题,使用productVariantUpdate()代替,您只需将所有的变体放到一个列表中,然后使用此突变对它们进行循环。
https://stackoverflow.com/questions/71248310
复制相似问题