Skip to content

Commit

Permalink
docs: fix typo in extend core flow (#10709)
Browse files Browse the repository at this point in the history
* docs: fix typo in extend core flow

* small fixes
  • Loading branch information
shahednasser authored Dec 23, 2024
1 parent 13ddf27 commit a4335f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Learn more about the workflow hooks in [this chapter](../../../fundamentals/work

</Note>

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:

Expand Down Expand Up @@ -171,16 +171,19 @@ 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)

```ts title="src/api/middlewares.ts"
import { defineMiddlewares } from "@medusajs/framework/http"
import { z } from "zod"

// ...

export default defineMiddlewares({
routes: [
// ...
{
matcher: "/admin/products",
method: ["POST"],
Expand Down
2 changes: 1 addition & 1 deletion www/apps/book/generated/edit-dates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit a4335f2

Please sign in to comment.