---
title: "productVariant"
description: "按 ID 返回 ProductVariant 资源。"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/queries/product-variant'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/queries/product-variant.md'
---
# productVariant

按 ID 返回 ProductVariant 资源。

- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Query

## Type Signature

`ProductVariant`

## Arguments

* `id`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  要返回的产品变体ID。

## Returns

* `availableForSale`

  [Boolean!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/boolean.md)

  可供出售的变体的可用性

* `barcode`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  与产品关联的条形码的值

* `compareAtPrice`

  [Money](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/money.md)

  该变体的原始价格，使用商店的默认货币

* `createdAt`

  [Date!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/date.md)

  创建变体的日期和时间

* `defaultCursor`

  [String!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  返回下一个变体的默认光标，按变体 ID 升序排序

* `displayName`

  [String!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  变体的显示名称，源自产品标题和变体标题

* `id`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  产品变体的ID，通用的唯一标识符

* `image`

  [Image](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/image.md)

  变体图片

* `inventoryItem`

  [InventoryItem!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/inventory/objects/inventory-item.md)

  产品库存项目，用于查询库存信息

* `inventoryPolicy`

  [ProductVariantInventoryPolicy](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/inventory/enums/product-variant-inventory-policy.md)

  库存耗尽时是否可以订购产品变体

* `inventoryQuantity`

  [Int](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/int.md)

  产品变体的可销售总数量

* `price`

  [Money](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/money.md)

  以默认商店货币表示的产品变体的价格

* `product`

  [Product](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/products-and-collections/objects/product.md)

  该变体所属的产品

* `productId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  该变体所属的产品ID

* `selectedOptions`

  [[SelectedOption!]](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/objects/selected-option.md)

  应用于变体的产品选项列表

* `sku`

  [String](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  产品变体的 SKU，区分大小写的字符串

* `taxable`

  [Boolean!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/boolean.md)

  该变体在出售时是否需征税

* `title`

  [String!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/string.md)

  产品变体的标题

* `updatedAt`

  [Date!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/date.md)

  上次修改产品变型的日期和时间

* `weight`

  [Float](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/float.md)

  产品变型的重量（以 weight_unit 定义的单位表示）

* `weightUnit`

  [WeightUnit](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common-objects/enums/weight-unit.md)

  变体重量的测量单位。如果未指定 `weight_unit`，则将应用商店的默认测量单位

## Code Example

```graphql
 {
	productVariant(id ) 
		 {
			# ProductVariant fields
		}
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

