createProductsWorkflow - Medusa Core Workflows Reference
This documentation provides a reference to the createProductsWorkflow
. It belongs to the @medusajs/medusa/core-flows
package.
This workflow creates one or more products. It's used by the Create Product Admin API Route. It can also be useful to you when creating seed scripts, for example.
This workflow has a hook that allows you to perform custom actions on the created products. You can see an example in this guide.
You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around product creation.
Source CodeExamples#
Steps#
Workflow hook
Step conditioned by when
View step details
Input#
CreateProductsWorkflowInput
CreateProductsWorkflowInputThe data to create one or more products, along with custom data that's passed to the workflow's hooks.
CreateProductsWorkflowInput
CreateProductsWorkflowInputproducts
CreateProductWorkflowInputDTO[]The products to create.
products
CreateProductWorkflowInputDTO[]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#
ProductDTO[]
ProductDTO[]
ProductDTO[]
ProductDTO[]id
stringThe ID of the product.
id
stringtitle
stringThe title of the product.
title
stringhandle
stringThe handle of the product. The handle can be used to create slug URL paths.
handle
stringsubtitle
null | stringThe subttle of the product.
subtitle
null | stringdescription
null | stringThe description of the product.
description
null | stringis_giftcard
booleanWhether the product is a gift card.
is_giftcard
booleanstatus
ProductStatusThe status of the product.
status
ProductStatusthumbnail
null | stringThe URL of the product's thumbnail.
thumbnail
null | stringwidth
null | numberThe width of the product.
width
null | numberweight
null | numberThe weight of the product.
weight
null | numberlength
null | numberThe length of the product.
length
null | numberheight
null | numberThe height of the product.
height
null | numberorigin_country
null | stringThe origin country of the product.
origin_country
null | stringhs_code
null | stringThe HS Code of the product.
hs_code
null | stringmid_code
null | stringThe MID Code of the product.
mid_code
null | stringmaterial
null | stringThe material of the product.
material
null | stringThe associated product collection.
collection_id
null | stringThe associated product collection id.
collection_id
null | stringThe associated product type.
type_id
null | stringThe associated product type id.
type_id
null | stringThe associated product tags.
The associated product variants.
The associated product options.
The associated product images.
external_id
null | stringThe ID of the product in an external system. This is useful if you're integrating the product with a third-party service and want to maintain
a reference to the ID in the integrated service.
external_id
null | stringcreated_at
string | DateWhen the product was created.
created_at
string | Dateupdated_at
string | DateWhen the product was updated.
updated_at
string | Datedeleted_at
string | DateWhen the product was deleted.
deleted_at
string | DateThe associated product categories.
discountable
booleanOptionalWhether the product can be discounted.
discountable
booleanOptionalHolds custom data in key-value pairs.
Hooks#
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.
productsCreated#
Handlers consuming this hook accept the following input.
invoke
InvokeFn<object, TOutput, TCompensateInput>