batchProductVariantsWorkflow - Medusa Core Workflows Reference

This documentation provides a reference to the batchProductVariantsWorkflow. It belongs to the @medusajs/medusa/core-flows package.

This workflow creates, updates, and deletes product variants. It's used by the Manage Variants in a Product Admin API Route.

You can use this workflow within your own customizations or custom workflows to manage the variants of a product. You can also use this within a seed script or in a custom import script.

Source Code

Examples#

Steps#

Input#

BatchProductVariantsWorkflowInputBatchProductVariantsWorkflowInput
The product variants to manage.
Records to create in bulk.
Records to update in bulk.
deletestring[]Optional
Records to delete in bulk.

Output#

BatchProductVariantsWorkflowOutputBatchProductVariantsWorkflowOutput
The result of managing the product variants.
The records that were created in the bulk operation.
The records that were updated in the bulk operation.
deletedstring[]
The IDs of the records deleted in the bulk operation.

Emitted Events#

This section lists the events that are either triggered by the emitEventStep in the workflow, or by another workflow executed within this workflow.

You can listen to these events in a subscriber, as explained in the Subscribers documentation.

Event

Description

Payload

Action

product-variant.updated

Emitted when product variants are updated.

[{
  id, // The ID of the product variant
}]

product-variant.created

Emitted when product variants are created.

[{
  id, // The ID of the product variant
}]

product-variant.deleted

Emitted when product variants are deleted.

[{
  id, // The ID of the product variant
}]
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break