From a4335f2a4791fda8c963f03688d2605f31b4d9a2 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Mon, 23 Dec 2024 18:10:31 +0200 Subject: [PATCH] docs: fix typo in extend core flow (#10709) * docs: fix typo in extend core flow * small fixes --- .../extend-features/extend-create-product/page.mdx | 7 +++++-- www/apps/book/generated/edit-dates.mjs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/www/apps/book/app/learn/customization/extend-features/extend-create-product/page.mdx b/www/apps/book/app/learn/customization/extend-features/extend-create-product/page.mdx index d15925a15c056..8a2d788a184ad 100644 --- a/www/apps/book/app/learn/customization/extend-features/extend-create-product/page.mdx +++ b/www/apps/book/app/learn/customization/extend-features/extend-create-product/page.mdx @@ -46,7 +46,7 @@ Learn more about the workflow hooks in [this chapter](../../../fundamentals/work -The [createProductsWorkflow](!resources!/references/medusa-workflows/createProductsWorkflow) used in the [Create Product API route](!api!/admin#products_postproducts) has a `productsCreated` hook that runs after the product is created. You'll consume this hook to link the created product with the brand specified in the request paramters. +The [createProductsWorkflow](!resources!/references/medusa-workflows/createProductsWorkflow) used in the [Create Product API route](!api!/admin#products_postproducts) has a `productsCreated` hook that runs after the product is created. You'll consume this hook to link the created product with the brand specified in the request parameters. To consume the `productsCreated` hook, create the file `src/workflows/hooks/created-product.ts` with the following content: @@ -171,7 +171,7 @@ In the compensation function, if the `links` parameter isn't empty, you resolve Now that you've consumed the `productCreated` hook, you want to configure the `/admin/products` API route that creates a new product to accept a brand ID in its `additional_data` parameter. -You configure the properties accepted in `additional_data` in the `src/api/middlewares.ts` that exports middleware configurations. So, create `src/api/middlewares.ts` with the following content: +You configure the properties accepted in `additional_data` in the `src/api/middlewares.ts` that exports middleware configurations. So, create the file (or, if already existing, add to the file) `src/api/middlewares.ts` the following content: ![Directory structure after adding the middelwares file](https://res.cloudinary.com/dza7lstvk/image/upload/v1733386868/Medusa%20Book/brands-middleware-dir-overview_uczos1.jpg) @@ -179,8 +179,11 @@ You configure the properties accepted in `additional_data` in the `src/api/middl import { defineMiddlewares } from "@medusajs/framework/http" import { z } from "zod" +// ... + export default defineMiddlewares({ routes: [ + // ... { matcher: "/admin/products", method: ["POST"], diff --git a/www/apps/book/generated/edit-dates.mjs b/www/apps/book/generated/edit-dates.mjs index 021b1bb43f677..54642e30ee321 100644 --- a/www/apps/book/generated/edit-dates.mjs +++ b/www/apps/book/generated/edit-dates.mjs @@ -86,7 +86,7 @@ export const generatedEditDates = { "app/learn/customization/custom-features/api-route/page.mdx": "2024-12-09T10:39:30.046Z", "app/learn/customization/custom-features/module/page.mdx": "2024-12-09T14:36:02.100Z", "app/learn/customization/custom-features/workflow/page.mdx": "2024-12-09T14:36:29.482Z", - "app/learn/customization/extend-features/extend-create-product/page.mdx": "2024-12-09T12:59:23.364Z", + "app/learn/customization/extend-features/extend-create-product/page.mdx": "2024-12-23T15:42:23.863Z", "app/learn/customization/custom-features/page.mdx": "2024-12-09T10:46:28.593Z", "app/learn/customization/customize-admin/page.mdx": "2024-12-09T11:02:38.801Z", "app/learn/customization/customize-admin/route/page.mdx": "2024-12-09T15:32:46.656Z",