diff --git a/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts b/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts index 0feb66d1079f3..c94fd19416e6c 100644 --- a/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts +++ b/packages/core/core-flows/src/product-category/workflows/create-product-categories.ts @@ -3,6 +3,7 @@ import { ProductCategoryWorkflowEvents } from "@medusajs/framework/utils" import { WorkflowData, WorkflowResponse, + createHook, createWorkflow, transform, } from "@medusajs/framework/workflows-sdk" @@ -18,12 +19,12 @@ export const createProductCategoriesWorkflow = createWorkflow( ( input: WorkflowData ) => { - const createdProducts = createProductCategoriesStep(input) + const createdProductCategories = createProductCategoriesStep(input) const productCategoryIdEvents = transform( - { createdProducts }, - ({ createdProducts }) => { - return createdProducts.map((v) => { + { createdProductCategories }, + ({ createdProductCategories }) => { + return createdProductCategories.map((v) => { return { id: v.id } }) } @@ -34,6 +35,13 @@ export const createProductCategoriesWorkflow = createWorkflow( data: productCategoryIdEvents, }) - return new WorkflowResponse(createdProducts) + const productCategoriesCreated = createHook("productCategoriesCreated", { + createdProductCategories, + additional_data: input.additional_data, + }) + + return new WorkflowResponse(createdProductCategories, { + hooks: [productCategoriesCreated] + }) } )