Skip to main content

ProductVariant Object

Represents a version of a product such as different size or color.

type ProductVariant implements Node, ObjectWithMetadata, ObjectWithAttributes {
id: ID!
privateMetadata: [MetadataItem!]!
privateMetafield(
key: String!
): String
privateMetafields(
keys: [String!]
): Metadata
metadata: [MetadataItem!]!
metafield(
key: String!
): String
metafields(
keys: [String!]
): Metadata
assignedAttribute(
slug: String!
): AssignedAttribute
assignedAttributes(
limit: PositiveInt = 100
): [AssignedAttribute!]!
name: String!
sku: String
product: Product!
trackInventory: Boolean!
quantityLimitPerCustomer: Int
weight: Weight
channel: String
channelListings: [ProductVariantChannelListing!]
pricing(
address: AddressInput
): VariantPricingInfo
attributes(
variantSelection: VariantAttributeScope
): [SelectedAttribute!]! @deprecated
margin: Int
quantityOrdered: Int
revenue(
period: ReportingPeriod
): TaxedMoney
images: [ProductImage!] @deprecated
media: [ProductMedia!]
translation(
languageCode: LanguageCodeEnum!
): ProductVariantTranslation
stocks(
address: AddressInput
countryCode: CountryCode
): [Stock!]
quantityAvailable(
address: AddressInput
countryCode: CountryCode
): Int
preorder: PreorderData @deprecated
created: DateTime!
updatedAt: DateTime!
externalReference: String
}

Fields​

id ● ID!​

The ID of the product variant.

privateMetadata ● [MetadataItem!]!​

List of private metadata items. Requires staff permissions to access.

privateMetafield ● String​

A single key from private metadata. Requires staff permissions to access.

Tip: Use GraphQL aliases to fetch multiple keys.

key ● String!​

privateMetafields ● Metadata​

Private metadata. Requires staff permissions to access. Use keys to control which fields you want to include. The default is to include everything.

keys ● [String!]​

metadata ● [MetadataItem!]!​

List of public metadata items. Can be accessed without permissions.

metafield ● String​

A single key from public metadata.

Tip: Use GraphQL aliases to fetch multiple keys.

key ● String!​

metafields ● Metadata​

Public metadata. Use keys to control which fields you want to include. The default is to include everything.

keys ● [String!]​

assignedAttribute ● AssignedAttribute​

Get a single attribute attached to product by attribute slug.

Added in Saleor 3.22
slug ● String!​

Slug of the attribute

assignedAttributes ● [AssignedAttribute!]!​

List of attributes assigned to this variant.

Added in Saleor 3.22
limit ● PositiveInt​

Maximum number of attributes to return. Default is 100.

name ● String!​

The name of the product variant.

sku ● String​

The SKU (stock keeping unit) of the product variant.

product ● Product!​

The product to which the variant belongs.

trackInventory ● Boolean!​

Determines if the inventory of this variant should be tracked. If false, the quantity won't change when customers buy this item. If the field is not provided, Shop.trackInventoryByDefault will be used.

quantityLimitPerCustomer ● Int​

The maximum quantity of this variant that a customer can purchase.

weight ● Weight​

The weight of the product variant.

channel ● String​

Channel given to retrieve this product variant. Also used by federation gateway to resolve this object in a federated query.

channelListings ● [ProductVariantChannelListing!]​

List of price information in channels for the product.

Requires one of the following permissions: AUTHENTICATED_APPAUTHENTICATED_STAFF_USER

pricing ● VariantPricingInfo​

Lists the storefront variant's pricing, the current price and discounts, only meant for displaying.

address ● AddressInput​

Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses Shop.companyAddress or fallbacks to server's settings.DEFAULT_COUNTRY configuration.

margin ● Int​

Gross margin percentage value.

quantityOrdered ● Int​

Total quantity ordered.

Requires the MANAGE_PRODUCTSpermission.

revenue ● TaxedMoney​

Total revenue generated by a variant in given period of time. Note: this field should be queried using reportProductSales query as it uses optimizations suitable for such calculations.

Requires the MANAGE_PRODUCTSpermission.
period ● ReportingPeriod​

media ● [ProductMedia!]​

List of media for the product variant.

translation ● ProductVariantTranslation​

Returns translated product variant fields for the given language code.

languageCode ● LanguageCodeEnum!​

A language code to return the translation for product variant.

stocks ● [Stock!]​

Stocks for the product variant.

Requires one of the following permissions: MANAGE_PRODUCTSMANAGE_ORDERS
address ● AddressInput​
DEPRECATED

No longer supported

Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses Shop.companyAddress or fallbacks to server's settings.DEFAULT_COUNTRY configuration. When Shop.useLegacyShippingZoneStockAvailability is disabled, this argument is ignored — stock availability is determined by the direct warehouse-channel link instead of shipping zones.

countryCode ● CountryCode​
DEPRECATED

Use address argument instead.

Two-letter ISO 3166-1 country code.

quantityAvailable ● Int​

Quantity of a product available for sale in one checkout. Field value will be null when no limitQuantityPerCheckout in global settings has been set, and productVariant stocks are not tracked.

address ● AddressInput​
DEPRECATED

No longer supported

Destination address used to find warehouses where stock availability for this product is checked. If address is empty, uses Shop.companyAddress or fallbacks to server's settings.DEFAULT_COUNTRY configuration. When Shop.useLegacyShippingZoneStockAvailability is disabled, this argument is ignored — stock availability is determined by the direct warehouse-channel link instead of shipping zones.

countryCode ● CountryCode​
DEPRECATED

Use address argument instead.

Two-letter ISO 3166-1 country code. When provided, the exact quantity from a warehouse operating in shipping zones that contain this country will be returned. Otherwise, it will return the maximum quantity from all shipping zones.

created ● DateTime!​

The date and time when the product variant was created.

updatedAt ● DateTime!​

The date and time when the product variant was last updated.

externalReference ● String​

External ID of this product.

Show deprecatedHide deprecated

attributes ● [SelectedAttribute!]!​

DEPRECATED

Use the assignedAttributes field instead.

List of attributes assigned to this variant.

variantSelection ● VariantAttributeScope​

Define scope of returned attributes.

images ● [ProductImage!]​

DEPRECATED

Use the media field instead.

List of images for the product variant.

preorder ● PreorderData​

DEPRECATED

Preorder is deprecated and will be removed. Model pre-sales with regular stock instead: create the planned quantity in a warehouse, or set trackInventory to false to sell without a stock limit.

Preorder data for product variant.

Interfaces​

Node​

An object with an ID

ObjectWithMetadata​

ObjectWithAttributes​

An object with attributes.

Added in Saleor 3.22

Returned By​

productVariant query

Member Of​

AssignedMultiProductVariantReferenceAttribute object ● AssignedSingleProductVariantReferenceAttribute object ● CheckoutLine object ● CheckoutLineProblemInsufficientStock object ● OrderLine object ● Product object ● ProductVariantBackInStock object ● ProductVariantBackInStockForClickAndCollect object ● ProductVariantBackInStockInChannel object ● ProductVariantBulkCreate object ● ProductVariantBulkResult object ● ProductVariantChannelListingUpdate object ● ProductVariantCountableEdge object ● ProductVariantCreate object ● ProductVariantCreated object ● ProductVariantDelete object ● ProductVariantDeleted object ● ProductVariantDiscountedPriceUpdated object ● ProductVariantMetadataUpdated object ● ProductVariantOutOfStock object ● ProductVariantOutOfStockForClickAndCollect object ● ProductVariantOutOfStockInChannel object ● ProductVariantPreorderDeactivate object ● ProductVariantReorderAttributeValues object ● ProductVariantStocksCreate object ● ProductVariantStocksDelete object ● ProductVariantStocksUpdate object ● ProductVariantStockUpdated object ● ProductVariantTranslatableContent object ● ProductVariantTranslate object ● ProductVariantUpdate object ● ProductVariantUpdated object ● Stock object ● VariantMediaAssign object ● VariantMediaUnassign object

Implemented By​

_Entity union