Skip to content

Commit 178a7f4

Browse files
authored
docs: document variant inventory conceptual guide (medusajs#11280)
* docs: document variant inventory conceptual guide * add notes * fix vale error * fix vale error
1 parent 016e332 commit 178a7f4

File tree

18 files changed

+213
-39
lines changed

18 files changed

+213
-39
lines changed

www/apps/resources/app/commerce-modules/inventory/links-to-other-modules/page.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ Each product variant has different inventory details. Medusa defines a link betw
3131

3232
A product variant whose `manage_inventory` property is enabled has an associated inventory item. Through that inventory's items relations in the Inventory Module, you can manage and check the variant's inventory quantity.
3333

34+
<Note title="Tip">
35+
36+
Learn more about product variant's inventory management in [this guide](../../product/variant-inventory/page.mdx).
37+
38+
</Note>
39+
3440
### Retrieve with Query
3541

3642
To retrieve the product variants of an inventory item with [Query](!docs!/learn/fundamentals/module-links/query), pass `variants.*` in `fields`:

www/apps/resources/app/commerce-modules/product/links-to-other-modules/page.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ Medusa defines a link between the `ProductVariant` and `InventoryItem` data mode
9090

9191
When the `manage_inventory` property of a product variant is enabled, you can manage the variant's inventory in different locations through this relation.
9292

93+
<Note title="Tip">
94+
95+
Learn more about product variant's inventory management in [this guide](../variant-inventory/page.mdx).
96+
97+
</Note>
98+
9399
### Retrieve with Query
94100

95101
To retrieve the inventory items of a product variant with [Query](!docs!/learn/fundamentals/module-links/query), pass `inventory_items.*` in `fields`:
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: "Product Variant Inventory"
3+
tags:
4+
- concept
5+
- inventory
6+
- stock location
7+
- sales channel
8+
---
9+
10+
export const metadata = {
11+
title: `Product Variant Inventory`,
12+
}
13+
14+
# {metadata.title}
15+
16+
In this guide, you'll learn about the inventory management features related to product variants.
17+
18+
## Configure Inventory Management of Product Variants
19+
20+
A product variant, represented by the [ProductVariant](/references/product/models/ProductVariant) data model, has a `manage_inventory` field that's disabled by default. This field indicates whether you'll manage the inventory quantity of the product variant.
21+
22+
The Product Module doesn't provide inventory-management features. Instead, the Medusa application uses the [Inventory Module](../../inventory/page.mdx) to manage inventory for products and variants. When `manage_inventory` is disabled, the Medusa application always considers the product variant to be in stock. This is useful if your product's variants aren't items that can be stocked, such as digital products, or they don't have a limited stock quantity.
23+
24+
When `manage_inventory` is enabled, the Medusa application tracks the inventory of the product variant using the [Inventory Module](../../inventory/page.mdx). For example, when a customer purchases a product variant, the Medusa application decrements the stocked quantity of the product variant.
25+
26+
---
27+
28+
## How the Medusa Application Manages Inventory
29+
30+
When a product variant has `manage_inventory` enabled, the Medusa application creates an inventory item using the [Inventory Module](../../inventory/page.mdx) and links it to the product variant.
31+
32+
![Diagram showcasing the link between a product variant and its inventory item](https://res.cloudinary.com/dza7lstvk/image/upload/v1709652779/Medusa%20Resources/product-inventory_kmjnud.jpg)
33+
34+
The inventory item has one or more locations, called inventory levels, that represent the stock quantity of the product variant at a specific location. This allows you to manage inventory across multiple warehouses, such as a warehouse in the US and another in Europe.
35+
36+
![Diagram showcasing the link between a variant and its inventory item, and the inventory item's level.](https://res.cloudinary.com/dza7lstvk/image/upload/v1738580390/Medusa%20Resources/variant-inventory-level_bbee2t.jpg)
37+
38+
<Note title="Tip">
39+
40+
Learn more about inventory concepts in the [Inventory Module's documentation](../../inventory/concepts/page.mdx).
41+
42+
</Note>
43+
44+
The Medusa application represents and manages stock locations using the [Stock Location Module](../../stock-location/page.mdx). It creates a read-only link between the `InventoryLevel` and `StockLocation` data models so that it can retrieve the stock location of an inventory level.
45+
46+
![Diagram showcasing the read-only link between an inventory level and a stock location](https://res.cloudinary.com/dza7lstvk/image/upload/v1738582163/Medusa%20Resources/inventory-level-stock_amxfg5.jpg)
47+
48+
<Note title="Tip">
49+
50+
Learn more about the Stock Location Module in the [Stock Location Module's documentation](../../stock-location/concepts/page.mdx).
51+
52+
</Note>
53+
54+
### Product Inventory in Storefronts
55+
56+
When a storefront sends a request to the Medusa application, it must always pass a [publishable API key](../../sales-channel/publishable-api-keys/page.mdx) in the request header. This API key specifies the sales channels, available through the [Sales Channel Module](../../sales-channel/page.mdx), of the storefront.
57+
58+
The Medusa application links sales channels to stock locations, indicating the locations available for a specific sales channel. So, all inventory-related operations are scoped by the sales channel and its associated stock locations.
59+
60+
For example, the availability of a product variant is determined by the `stocked_quantity` of its inventory level at the stock location linked to the storefront's sales channel.
61+
62+
![Diagram showcasing the overall relations between inventory, stock location, and sales channel concepts](https://res.cloudinary.com/dza7lstvk/image/upload/v1738582163/Medusa%20Resources/inventory-stock-sales_fknoxw.jpg)
63+
64+
---
65+
66+
## Variant Back Orders
67+
68+
Product variants have an `allow_backorder` field that's disabled by default. When enabled, the Medusa application allows customers to purchase the product variant even when it's out of stock. Use this when your product variant is available through on-demand or pre-order purchase.
69+
70+
<Note title="Tip">
71+
72+
You can also allow customers to subscribe to restock notifications of a product variant as explained in [this guide](../../../recipes/commerce-automation/restock-notification/page.mdx).
73+
74+
</Note>
75+
76+
---
77+
78+
## Additional Resources
79+
80+
The following guides provide more details on inventory management in the Medusa application:
81+
82+
- [Inventory Kits in the Inventory Module](../../inventory/inventory-kit/page.mdx): Learn how you can implement bundled or multi-part products through the Inventory Module.
83+
- [Inventory in Flows](../../inventory/inventory-in-flows/page.mdx): Learn how Medusa utilizes inventory management in different flows.
84+
- [Storefront guide: how to retrieve a product variant's inventory details](https://docs.medusajs.com/resources/storefront-development/products/inventory).

www/apps/resources/generated/edit-dates.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,10 +2115,10 @@ export const generatedEditDates = {
21152115
"app/commerce-modules/cart/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.593Z",
21162116
"app/commerce-modules/customer/extend/page.mdx": "2024-12-25T15:54:37.789Z",
21172117
"app/commerce-modules/fulfillment/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.593Z",
2118-
"app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.600Z",
2118+
"app/commerce-modules/inventory/links-to-other-modules/page.mdx": "2025-02-03T12:37:33.622Z",
21192119
"app/commerce-modules/pricing/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.607Z",
21202120
"app/commerce-modules/product/extend/page.mdx": "2024-12-11T09:07:25.252Z",
2121-
"app/commerce-modules/product/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.606Z",
2121+
"app/commerce-modules/product/links-to-other-modules/page.mdx": "2025-02-03T12:37:18.919Z",
21222122
"app/commerce-modules/promotion/extend/page.mdx": "2024-12-11T09:07:24.137Z",
21232123
"app/commerce-modules/promotion/links-to-other-modules/page.mdx": "2025-01-06T11:19:35.608Z",
21242124
"app/commerce-modules/order/edit/page.mdx": "2024-10-09T08:50:05.334Z",
@@ -5902,5 +5902,6 @@ export const generatedEditDates = {
59025902
"references/types/HttpTypes/interfaces/types.HttpTypes.StoreProductTypeResponse/page.mdx": "2025-01-27T11:43:54.212Z",
59035903
"references/types/interfaces/types.BaseProductTypeListParams/page.mdx": "2025-01-27T11:43:54.550Z",
59045904
"references/core_flows/Order/Steps_Order/variables/core_flows.Order.Steps_Order.updateOrderChangesStepId/page.mdx": "2025-01-27T11:43:49.278Z",
5905-
"app/troubleshooting/test-errors/page.mdx": "2025-01-31T13:08:42.639Z"
5905+
"app/troubleshooting/test-errors/page.mdx": "2025-01-31T13:08:42.639Z",
5906+
"app/commerce-modules/product/variant-inventory/page.mdx": "2025-02-03T12:19:45.706Z"
59065907
}

www/apps/resources/generated/files-map.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,10 @@ export const filesMap = [
551551
"filePath": "/www/apps/resources/app/commerce-modules/product/page.mdx",
552552
"pathname": "/commerce-modules/product"
553553
},
554+
{
555+
"filePath": "/www/apps/resources/app/commerce-modules/product/variant-inventory/page.mdx",
556+
"pathname": "/commerce-modules/product/variant-inventory"
557+
},
554558
{
555559
"filePath": "/www/apps/resources/app/commerce-modules/product/workflows/page.mdx",
556560
"pathname": "/commerce-modules/product/workflows"

www/apps/resources/generated/sidebar.mjs

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,6 +4626,8 @@ export const generatedSidebar = [
46264626
"type": "category",
46274627
"title": "Concepts",
46284628
"initialOpen": false,
4629+
"autogenerate_tags": "concept+inventory",
4630+
"autogenerate_as_ref": true,
46294631
"children": [
46304632
{
46314633
"loaded": true,
@@ -4658,6 +4660,14 @@ export const generatedSidebar = [
46584660
"path": "/commerce-modules/inventory/links-to-other-modules",
46594661
"title": "Links to Modules",
46604662
"children": []
4663+
},
4664+
{
4665+
"loaded": true,
4666+
"isPathHref": true,
4667+
"type": "ref",
4668+
"title": "Product Variant Inventory",
4669+
"path": "/commerce-modules/product/variant-inventory",
4670+
"children": []
46614671
}
46624672
]
46634673
},
@@ -6647,14 +6657,6 @@ export const generatedSidebar = [
66476657
"path": "/references/medusa-workflows/steps/updateOrderChangesStep",
66486658
"children": []
66496659
},
6650-
{
6651-
"loaded": true,
6652-
"isPathHref": true,
6653-
"type": "ref",
6654-
"title": "updateOrderExchangesStep",
6655-
"path": "/references/medusa-workflows/steps/updateOrderExchangesStep",
6656-
"children": []
6657-
},
66586660
{
66596661
"loaded": true,
66606662
"isPathHref": true,
@@ -10338,6 +10340,14 @@ export const generatedSidebar = [
1033810340
"autogenerate_tags": "concept+product",
1033910341
"autogenerate_as_ref": true,
1034010342
"children": [
10343+
{
10344+
"loaded": true,
10345+
"isPathHref": true,
10346+
"type": "link",
10347+
"path": "/commerce-modules/product/variant-inventory",
10348+
"title": "Variant Inventory",
10349+
"children": []
10350+
},
1034110351
{
1034210352
"loaded": true,
1034310353
"isPathHref": true,
@@ -13200,6 +13210,8 @@ export const generatedSidebar = [
1320013210
"type": "category",
1320113211
"title": "Concepts",
1320213212
"initialOpen": false,
13213+
"autogenerate_tags": "concept+salesChannel",
13214+
"autogenerate_as_ref": true,
1320313215
"children": [
1320413216
{
1320513217
"loaded": true,
@@ -13216,6 +13228,14 @@ export const generatedSidebar = [
1321613228
"path": "/commerce-modules/sales-channel/links-to-other-modules",
1321713229
"title": "Links to Modules",
1321813230
"children": []
13231+
},
13232+
{
13233+
"loaded": true,
13234+
"isPathHref": true,
13235+
"type": "ref",
13236+
"title": "Product Variant Inventory",
13237+
"path": "/commerce-modules/product/variant-inventory",
13238+
"children": []
1321913239
}
1322013240
]
1322113241
},
@@ -13640,6 +13660,8 @@ export const generatedSidebar = [
1364013660
"type": "category",
1364113661
"title": "Concepts",
1364213662
"initialOpen": false,
13663+
"autogenerate_tags": "concept+stockLocation",
13664+
"autogenerate_as_ref": true,
1364313665
"children": [
1364413666
{
1364513667
"loaded": true,
@@ -13656,6 +13678,22 @@ export const generatedSidebar = [
1365613678
"path": "/commerce-modules/stock-location/links-to-other-modules",
1365713679
"title": "Links to Modules",
1365813680
"children": []
13681+
},
13682+
{
13683+
"loaded": true,
13684+
"isPathHref": true,
13685+
"type": "ref",
13686+
"title": "Inventory Kits",
13687+
"path": "/commerce-modules/inventory/inventory-kit",
13688+
"children": []
13689+
},
13690+
{
13691+
"loaded": true,
13692+
"isPathHref": true,
13693+
"type": "ref",
13694+
"title": "Product Variant Inventory",
13695+
"path": "/commerce-modules/product/variant-inventory",
13696+
"children": []
1365913697
}
1366013698
]
1366113699
},

www/apps/resources/sidebars/inventory.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const inventorySidebar = [
1717
type: "category",
1818
title: "Concepts",
1919
initialOpen: false,
20+
autogenerate_tags: "concept+inventory",
21+
autogenerate_as_ref: true,
2022
children: [
2123
{
2224
type: "link",

www/apps/resources/sidebars/product.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export const productSidebar = [
2020
autogenerate_tags: "concept+product",
2121
autogenerate_as_ref: true,
2222
children: [
23+
{
24+
type: "link",
25+
path: "/commerce-modules/product/variant-inventory",
26+
title: "Variant Inventory",
27+
},
2328
{
2429
type: "link",
2530
path: "/commerce-modules/product/links-to-other-modules",

www/apps/resources/sidebars/sales-channel.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const salesChannelSidebar = [
1717
type: "category",
1818
title: "Concepts",
1919
initialOpen: false,
20+
autogenerate_tags: "concept+salesChannel",
21+
autogenerate_as_ref: true,
2022
children: [
2123
{
2224
type: "link",

www/apps/resources/sidebars/stock-location.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const stockLocationSidebar = [
1717
type: "category",
1818
title: "Concepts",
1919
initialOpen: false,
20+
autogenerate_tags: "concept+stockLocation",
21+
autogenerate_as_ref: true,
2022
children: [
2123
{
2224
type: "link",

0 commit comments

Comments
 (0)