- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
updateProductVariantsWorkflow - Medusa Core Workflows Reference
This documentation provides a reference to the updateProductVariantsWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow updates one or more product variants. It's used by the Update Product Variant Admin API Route.
This workflow has a hook that allows you to perform custom actions on the updated product variants. For example, you can pass under additional_data
custom data that
allows you to update custom data models linked to the product variants.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product-variant update.
Source CodeExamples#
To update product variants by their IDs:
You can also update product variants by a selector:
Steps#
Workflow Hook
Step conditioned by when
Input#
UpdateProductVariantsWorkflowInput
UpdateProductVariantsWorkflowInputThe data to update one or more product variants, along with custom data that's passed to the workflow's hooks.
UpdateProductVariantsWorkflowInput
UpdateProductVariantsWorkflowInputselector
FilterableProductVariantPropsA filter to select the product variants to update.
selector
FilterableProductVariantPropsupdate
UpdateProductVariantDTO & objectThe data to update in the product variants.
update
UpdateProductVariantDTO & objectproduct_variants
UpsertProductVariantDTO & object[]The product variants to update.
product_variants
UpsertProductVariantDTO & object[]additional_data
Record<string, unknown>OptionalAdditional data that can be passed through the additional_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown>Optionaladditional_data
property in HTTP requests.
Learn more in this documentation.Output#
object[]
object[]
object[]
object[]price_set
undefined | PriceSetDTODefault: priceSetForVariant
price_set
undefined | PriceSetDTOpriceSetForVariant
id
stringThe ID of the product variant.
id
stringtitle
stringThe tile of the product variant.
title
stringsku
null | stringThe SKU of the product variant.
sku
null | stringbarcode
null | stringThe barcode of the product variant.
barcode
null | stringean
null | stringThe EAN of the product variant.
ean
null | stringupc
null | stringThe UPC of the product variant.
upc
null | stringallow_backorder
booleanWhether the product variant can be ordered when it's out of stock.
allow_backorder
booleanmanage_inventory
booleanWhether the product variant's inventory should be managed by the core system.
manage_inventory
booleanrequires_shipping
booleanWhether the product variant's requires shipping.
requires_shipping
booleanhs_code
null | stringThe HS Code of the product variant.
hs_code
null | stringorigin_country
null | stringThe origin country of the product variant.
origin_country
null | stringmid_code
null | stringThe MID Code of the product variant.
mid_code
null | stringmaterial
null | stringThe material of the product variant.
material
null | stringweight
null | numberThe weight of the product variant.
weight
null | numberlength
null | numberThe length of the product variant.
length
null | numberheight
null | numberThe height of the product variant.
height
null | numberwidth
null | numberThe width of the product variant.
width
null | numberThe associated product options.
metadata
null | Record<string, unknown>Holds custom data in key-value pairs.
metadata
null | Record<string, unknown>product_id
null | stringThe associated product id.
product_id
null | stringcreated_at
string | DateWhen the product variant was created.
created_at
string | Dateupdated_at
string | DateWhen the product variant was updated.
updated_at
string | Datedeleted_at
string | DateWhen the product variant was deleted.
deleted_at
string | DateThe associated product.
variant_rank
null | numberOptionalhe ranking of the variant among other variants associated with the product.
variant_rank
null | numberOptionalHooks#
Hooks allow you to inject custom functionalities into the workflow. You'll receive data from the workflow, as well as additional data sent through an HTTP request.
Learn more about Hooks and Additional Data.
productVariantsUpdated#
This hook is executed after the product variants are updated. You can consume this hook to perform custom actions on the updated product variants.
Example
Input
Handlers consuming this hook accept the following input.
input
objectThe input data for the hook.
input
objectproduct_variants
object[]
product_variants
object[]additional_data
Record<string, unknown> | undefinedAdditional data that can be passed through the additional\_data
property in HTTP requests.
Learn more in this documentation.
additional_data
Record<string, unknown> | undefinedadditional\_data
property in HTTP requests.
Learn more in this documentation.