docs: add documentation for product <> shipping profile link (#11397)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ The Fulfillment Module has the following links to other modules:
|
||||
- [`Order` data model of the Order Module \<\> `Fulfillment` data model](#order-module).
|
||||
- [`Return` data model of the Order Module \<\> `Fulfillment` data model](#order-module).
|
||||
- [`PriceSet` data model of the Pricing Module \<\> `ShippingOption` data model](#pricing-module).
|
||||
- [`Product` data model of the Product Module \<\> `ShippingProfile` data model](#product-module).
|
||||
- [`StockLocation` data model of the Stock Location Module \<\> `FulfillmentProvider` data model](#stock-location-module).
|
||||
- [`StockLocation` data model of the Stock Location Module \<\> `FulfillmentSet` data model](#stock-location-module).
|
||||
|
||||
@@ -216,6 +217,101 @@ createRemoteLinkStep({
|
||||
|
||||
---
|
||||
|
||||
## Product Module
|
||||
|
||||
Medusa defines a link between the `ShippingProfile` data model and the `Product` data model of the Product Module. Each product must belong to a shipping profile.
|
||||
|
||||
<Note>
|
||||
|
||||
This link is introduced in [Medusa v2.5.0](https://github.com/medusajs/medusa/releases/tag/v2.5.0).
|
||||
|
||||
</Note>
|
||||
|
||||
### Retrieve with Query
|
||||
|
||||
To retrieve the products of a shipping profile with [Query](!docs!/learn/fundamentals/module-links/query), pass `products.*` in `fields`:
|
||||
|
||||
<CodeTabs group="relation-query">
|
||||
<CodeTab label="query.graph" value="method">
|
||||
|
||||
```ts
|
||||
const { data: shippingProfiles } = await query.graph({
|
||||
entity: "shipping_profile",
|
||||
fields: [
|
||||
"products.*",
|
||||
],
|
||||
})
|
||||
|
||||
// shippingProfiles.products
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="useQueryGraphStep" value="step">
|
||||
|
||||
```ts
|
||||
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
|
||||
const { data: shippingProfiles } = useQueryGraphStep({
|
||||
entity: "shipping_profile",
|
||||
fields: [
|
||||
"products.*",
|
||||
],
|
||||
})
|
||||
|
||||
// shippingProfiles.products
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
### Manage with Link
|
||||
|
||||
To manage the shipping profile of a product, use [Link](!docs!/learn/fundamentals/module-links/link):
|
||||
|
||||
<CodeTabs group="relation-link">
|
||||
<CodeTab label="link.create" value="method">
|
||||
|
||||
```ts
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
|
||||
// ...
|
||||
|
||||
await link.create({
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: "sp_123",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="createRemoteLinkStep" value="step">
|
||||
|
||||
```ts
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
|
||||
createRemoteLinkStep({
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: "sp_123",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
---
|
||||
|
||||
## Stock Location Module
|
||||
|
||||
The Stock Location Module provides features to manage stock locations in a store.
|
||||
|
||||
@@ -19,6 +19,7 @@ Read-only links are used to query data across modules, but the relations aren't
|
||||
</Note>
|
||||
|
||||
- [`Product` data model \<\> `Cart` data model of Cart Module](#cart-module). (Read-only).
|
||||
- [`Product` data model \<\> `ShippingProfile` data model of Fulfillment Module](#fulfillment-module).
|
||||
- [`ProductVariant` data model \<\> `InventoryItem` data model of Inventory Module](#inventory-module).
|
||||
- [`Product` data model \<\> `Order` data model of Order Module](#order-module). (Read-only).
|
||||
- [`ProductVariant` data model \<\> `PriceSet` data model of Pricing Module](#pricing-module).
|
||||
@@ -80,6 +81,101 @@ const { data: variants } = useQueryGraphStep({
|
||||
|
||||
---
|
||||
|
||||
## Fulfillment Module
|
||||
|
||||
Medusa defines a link between the `Product` data model and the `ShippingProfile` data model of the Fulfillment Module. Each product must belong to a shipping profile.
|
||||
|
||||
<Note>
|
||||
|
||||
This link is introduced in [Medusa v2.5.0](https://github.com/medusajs/medusa/releases/tag/v2.5.0).
|
||||
|
||||
</Note>
|
||||
|
||||
### Retrieve with Query
|
||||
|
||||
To retrieve the shipping profile of a product with [Query](!docs!/learn/fundamentals/module-links/query), pass `shipping_profile.*` in `fields`:
|
||||
|
||||
<CodeTabs group="relation-query">
|
||||
<CodeTab label="query.graph" value="method">
|
||||
|
||||
```ts
|
||||
const { data: products } = await query.graph({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"shipping_profile.*",
|
||||
],
|
||||
})
|
||||
|
||||
// products.shipping_profile
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="useQueryGraphStep" value="step">
|
||||
|
||||
```ts
|
||||
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
|
||||
const { data: products } = useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: [
|
||||
"shipping_profile.*",
|
||||
],
|
||||
})
|
||||
|
||||
// products.shipping_profile
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
### Manage with Link
|
||||
|
||||
To manage the shipping profile of a product, use [Link](!docs!/learn/fundamentals/module-links/link):
|
||||
|
||||
<CodeTabs group="relation-link">
|
||||
<CodeTab label="link.create" value="method">
|
||||
|
||||
```ts
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
|
||||
// ...
|
||||
|
||||
await link.create({
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: "sp_123",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="createRemoteLinkStep" value="step">
|
||||
|
||||
```ts
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
|
||||
createRemoteLinkStep({
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: "prod_123",
|
||||
},
|
||||
[Modules.FULFILLMENT]: {
|
||||
shipping_profile_id: "sp_123",
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
---
|
||||
|
||||
## Inventory Module
|
||||
|
||||
The Inventory Module provides inventory-management features for any stock-kept item.
|
||||
|
||||
@@ -2114,11 +2114,11 @@ export const generatedEditDates = {
|
||||
"app/commerce-modules/cart/extend/page.mdx": "2024-12-25T12:48:59.149Z",
|
||||
"app/commerce-modules/cart/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.593Z",
|
||||
"app/commerce-modules/customer/extend/page.mdx": "2024-12-25T15:54:37.789Z",
|
||||
"app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.593Z",
|
||||
"app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2025-02-11T12:10:04.901Z",
|
||||
"app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2025-02-03T12:37:33.622Z",
|
||||
"app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.607Z",
|
||||
"app/commerce-modules/product/extend/page.mdx": "2024-12-11T09:07:25.252Z",
|
||||
"app/commerce-modules/product/links-to-other-modules/page.mdx": "2025-02-03T12:37:18.919Z",
|
||||
"app/commerce-modules/product/links-to-other-modules/page.mdx": "2025-02-11T12:09:46.420Z",
|
||||
"app/commerce-modules/promotion/extend/page.mdx": "2024-12-11T09:07:24.137Z",
|
||||
"app/commerce-modules/promotion/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.608Z",
|
||||
"app/commerce-modules/order/edit/page.mdx": "2024-10-09T08:50:05.334Z",
|
||||
|
||||
Reference in New Issue
Block a user