ProductVariantsResource
This class is used to send requests to Store Product Variant API Routes. All its method
are available in the JS Client under the medusa.product.variants
property.
Product variants are the actual salable item in your store. Each variant is a combination of the different option values available on the product.
Methods
list
Retrieves a list of product variants. The product variants can be filtered by fields such as id
or title
passed in the query
parameter. The product variants can also be paginated.
For accurate and correct pricing of the product variants based on the customer's context, it's highly recommended to pass fields such as
region_id
, currency_code
, and cart_id
when available.
Passing sales_channel_id
ensures retrieving only variants of products available in the specified sales channel.
You can alternatively use a publishable API key in the request header instead of passing a sales_channel_id
.
Example
To list product variants:
To specify relations that should be retrieved within the product variants:
By default, only the first 100
records are retrieved. You can control pagination by specifying the limit
and offset
properties:
Parameters
Filters and pagination configurations applied on the retrieved product variants.
customHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreVariantsListRes>RequiredResolves to the list of product variants.
ResponsePromise
ResponsePromise<StoreVariantsListRes>Requiredretrieve
Retrieve a Product Variant's details. For accurate and correct pricing of the product variant based on the customer's context, it's highly recommended to pass fields such as
region_id
, currency_code
, and cart_id
when available.
Passing sales_channel_id
ensures retrieving only variants of products available in the current sales channel.
You can alternatively use a publishable API key in the request header instead of passing a sales_channel_id
.
Example
Parameters
id
stringRequiredcustomHeaders
Record<string, any>RequiredDefault: {}
Returns
ResponsePromise
ResponsePromise<StoreVariantsRes>RequiredResolves to the product variant's details.
ResponsePromise
ResponsePromise<StoreVariantsRes>Required