docs: revise extend models (features) (#10429)
This commit is contained in:
@@ -832,7 +832,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin
|
||||
|
||||
This is useful if you want to extend an API route and pass additional data or perform custom actions.
|
||||
|
||||
Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-models/extend-create-product) to find an example of extending an API route.
|
||||
Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.
|
||||
|
||||
<Feedback
|
||||
event="survey_api-ref"
|
||||
|
||||
@@ -831,7 +831,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin
|
||||
|
||||
This is useful if you want to extend an API route and pass additional data or perform custom actions.
|
||||
|
||||
Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-models/extend-create-product) to find an example of extending an API route.
|
||||
Refer to [this guide](https://docs.medusajs.com/learn/customization/extend-features/extend-create-product) to find an example of extending an API route.
|
||||
|
||||
<Feedback
|
||||
event="survey_api-ref"
|
||||
|
||||
@@ -18,7 +18,7 @@ This chapter covers how to show the brand of a product in the Medusa Admin using
|
||||
items={[
|
||||
{
|
||||
text: "Retrieve Brand of Product API Route",
|
||||
link: "/learn/customization/extend-models/query-linked-records"
|
||||
link: "/learn/customization/extend-features/query-linked-records"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ It's useful when you want to pass custom data, such as the brand ID, then perfor
|
||||
},
|
||||
{
|
||||
text: "Defined link between the Brand and Product data models.",
|
||||
link: "/learn/customization/extend-models/define-link"
|
||||
link: "/learn/customization/extend-features/define-link"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
@@ -0,0 +1,25 @@
|
||||
export const metadata = {
|
||||
title: `${pageNumber} Extend Core Commerce Features`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In the upcoming chapters, you'll learn about the concepts and tools to extend Medusa's core commerce features.
|
||||
|
||||
In other commerce platforms, you extend core features and models through hacky workarounds that can introduce unexpected issues and side effects across the platform. It also makes your application difficult to maintain and upgrade in the long run.
|
||||
|
||||
Medusa's framework and orchestration tools mitigate these issues while supporting all your customization needs:
|
||||
|
||||
- [Module Links](../../advanced-development/module-links/page.mdx): Link data models of different modules without building direct dependencies, ensuring that the Medusa application integrates your modules without side effects.
|
||||
- [Workflow Hooks](../../advanced-development/workflows/workflow-hooks/page.mdx): inject custom functionalities into a workflow at predefined points, called hooks. This allows you to perform custom actions as a part of a core workflow without hacky workarounds.
|
||||
- [Additional Data in API Routes](../../advanced-development/api-routes/additional-data/page.mdx): Configure core API routes to accept request parameters relevant to your customizations. These parameters are passed to the underlying workflow's hooks, where you can manage your custom data as part of an existing flow.
|
||||
|
||||
---
|
||||
|
||||
## Next Chapters: Link Brands to Products Example
|
||||
|
||||
The next chapters explain how to use the tools mentioned above with step-by-step guides. You'll continue with the [brands example from the previous chapters](../custom-features/page.mdx) to:
|
||||
|
||||
- Link brands from the custom [Brand Module](../custom-features/module/page.mdx) to products from Medusa's [Product Module](!resources!/commerce-modules/product).
|
||||
- Extend the core product-creation workflow and the API route that uses it to allow setting the brand of a newly created product.
|
||||
- Retrieve a product's associated brand's details.
|
||||
+1
-1
@@ -28,7 +28,7 @@ Query is a utility that retrieves data across modules and their links. It’s re
|
||||
},
|
||||
{
|
||||
text: "Defined link between the Brand and Product data models.",
|
||||
link: "/learn/customization/extend-models/define-link"
|
||||
link: "/learn/customization/extend-features/define-link"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
@@ -1,40 +0,0 @@
|
||||
export const metadata = {
|
||||
title: `${pageNumber} How to Extend Data Models`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In this chapter, you'll learn about Medusa's alternative approach to extending data models.
|
||||
|
||||
## Extend Models Alternative: Module Links
|
||||
|
||||
Since modules are isolated from one another, it's not possible to directly extend a module's data models.
|
||||
|
||||
Instead, you define a link between the modules' data models.
|
||||
|
||||
### Why are Modules Isolated?
|
||||
|
||||
Some of the module isolation's benefits include:
|
||||
|
||||
- Integrate your module into any Medusa application without side-effects to your setup.
|
||||
- Replace existing modules with your custom implementation, if your use case is drastically different.
|
||||
- Use modules in other environments, such as Edge functions and Next.js apps.
|
||||
|
||||
### How does Medusa Manage Module Links?
|
||||
|
||||
When you define a link, the Medusa application creates a table in the database for it.
|
||||
|
||||
Then, when you create a link between two records, the Medusa application stores the IDs of the linked records in that table.
|
||||
|
||||
Medusa also provides the necessary tools to manage and query the linked records, which you'll learn about in the next chapters.
|
||||
|
||||
---
|
||||
|
||||
## Next Chapters: Link Brands to Products Example
|
||||
|
||||
The next chapters continue the brands example. It shows you how to:
|
||||
|
||||
- Link a brand, which you defined in a [previous example](../custom-features/module/page.mdx), to a product.
|
||||
- Manage linked records between the brands and products.
|
||||
- Extend Medusa's Create Product API route to link a product to a brand.
|
||||
- Query linked brands and products.
|
||||
@@ -92,15 +92,15 @@ export const generatedEditDates = {
|
||||
"app/learn/customization/custom-features/api-route/page.mdx": "2024-11-28T13:12:10.521Z",
|
||||
"app/learn/customization/custom-features/module/page.mdx": "2024-11-28T09:25:29.098Z",
|
||||
"app/learn/customization/custom-features/workflow/page.mdx": "2024-11-28T10:47:28.084Z",
|
||||
"app/learn/customization/extend-models/create-links/page.mdx": "2024-09-30T08:43:53.133Z",
|
||||
"app/learn/customization/extend-models/extend-create-product/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/extend-features/create-links/page.mdx": "2024-09-30T08:43:53.133Z",
|
||||
"app/learn/customization/extend-features/extend-create-product/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/custom-features/page.mdx": "2024-11-28T08:21:55.207Z",
|
||||
"app/learn/customization/customize-admin/page.mdx": "2024-09-12T12:25:29.853Z",
|
||||
"app/learn/customization/customize-admin/route/page.mdx": "2024-10-07T12:43:11.335Z",
|
||||
"app/learn/customization/customize-admin/widget/page.mdx": "2024-10-07T12:44:24.538Z",
|
||||
"app/learn/customization/extend-models/define-link/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/extend-models/page.mdx": "2024-09-12T12:38:57.394Z",
|
||||
"app/learn/customization/extend-models/query-linked-records/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/extend-features/define-link/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/extend-features/page.mdx": "2024-09-12T12:38:57.394Z",
|
||||
"app/learn/customization/extend-features/query-linked-records/page.mdx": "2024-09-30T08:43:53.134Z",
|
||||
"app/learn/customization/integrate-systems/handle-event/page.mdx": "2024-09-30T08:43:53.135Z",
|
||||
"app/learn/customization/integrate-systems/page.mdx": "2024-09-12T12:33:29.827Z",
|
||||
"app/learn/customization/integrate-systems/schedule-task/page.mdx": "2024-09-30T08:43:53.135Z",
|
||||
|
||||
@@ -160,18 +160,23 @@ const nextConfig = {
|
||||
{
|
||||
source: "/recipes/:path*",
|
||||
destination: "/resources/recipes",
|
||||
permanent: true
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/plugins/:path*",
|
||||
destination: "/v1/plugins/:path*",
|
||||
permanent: true
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/medusa-react/:path*",
|
||||
destination: "/v1/medusa-react/:path*",
|
||||
permanent: true
|
||||
}
|
||||
permanent: true,
|
||||
},
|
||||
{
|
||||
source: "/learn/customization/extend-models/:path*",
|
||||
destination: "/learn/customization/extend-features/:path*",
|
||||
permanent: true,
|
||||
},
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
@@ -115,28 +115,28 @@ export const sidebar = numberSidebarItems(
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
title: "Extend Models",
|
||||
path: "/learn/customization/extend-models",
|
||||
title: "Extend Features",
|
||||
path: "/learn/customization/extend-features",
|
||||
children: [
|
||||
{
|
||||
type: "link",
|
||||
title: "Define Link",
|
||||
path: "/learn/customization/extend-models/define-link",
|
||||
path: "/learn/customization/extend-features/define-link",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
title: "Create Links Between Records",
|
||||
path: "/learn/customization/extend-models/create-links",
|
||||
path: "/learn/customization/extend-features/create-links",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
title: "Extend Route",
|
||||
path: "/learn/customization/extend-models/extend-create-product",
|
||||
path: "/learn/customization/extend-features/extend-create-product",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
title: "Query Linked Records",
|
||||
path: "/learn/customization/extend-models/query-linked-records",
|
||||
path: "/learn/customization/extend-features/query-linked-records",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -378,7 +378,7 @@ In this example, you'll pass additional data to the Create Product API route, th
|
||||
|
||||
<Note>
|
||||
|
||||
Find this example in details in [this documentation](!docs!/learn/customization/extend-models/extend-create-product).
|
||||
Find this example in details in [this documentation](!docs!/learn/customization/extend-features/extend-create-product).
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user