Links between Product Module and Other Modules

This document showcases the module links defined between the Product Module and other Commerce Modules.

Summary#

The Product Module has the following links to other modules:

Tip: Read-only links are used to query data across modules, but the relations aren't stored in a pivot table in the database.

First Data Model

Second Data Model

Type

Description

LineItem in Cart Module

Product

Read-only - has one

Learn more

Product

ShippingProfile in Fulfillment Module

Stored - many-to-one

Learn more

ProductVariant

InventoryItem in Inventory Module

Stored - many-to-many

Learn more

OrderLineItem in Order Module

Product

Read-only - has one

Learn more

ProductVariant

PriceSet in Pricing Module

Stored - one-to-one

Learn more

Product

SalesChannel in Sales Channel Module

Stored - many-to-many

Learn more


Cart Module#

Medusa defines read-only links between:

  • The Cart Module's LineItem data model and the Product data model. Because the link is read-only from the LineItem's side, you can only retrieve the product of a line item, and not the other way around.
  • The ProductVariant data model and the Cart Module's LineItem data model. Because the link is read-only from the LineItem's side, you can only retrieve the variant of a line item, and not the other way around.

Retrieve with Query#

To retrieve the variant of a line item with Query, pass variant.* in fields:

Note: To retrieve the product, pass product.* in fields.

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.

Retrieve with Query#

To retrieve the shipping profile of a product with Query, pass shipping_profile.* in fields:

To manage the shipping profile of a product, use Link:


Inventory Module#

The Inventory Module provides inventory-management features for any stock-kept item.

Medusa defines a link between the ProductVariant and InventoryItem data models. Each product variant has different inventory details.

A diagram showcasing an example of how data models from the Product and Inventory modules are linked.

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

Tip: Learn more about product variant's inventory management in this guide.

Retrieve with Query#

To retrieve the inventory items of a product variant with Query, pass inventory_items.* in fields:

To manage the inventory items of a variant, use Link:


Order Module#

Medusa defines read-only links between:

  • the Order Module's OrderLineItem data model and the Product data model. Because the link is read-only from the OrderLineItem's side, you can only retrieve the product of an order line item, and not the other way around.
  • the Order Module's OrderLineItem data model and the ProductVariant data model. Because the link is read-only from the OrderLineItem's side, you can only retrieve the variant of an order line item, and not the other way around.

Retrieve with Query#

To retrieve the variant of a line item with Query, pass variant.* in fields:

Note: To retrieve the product, pass product.* in fields.

Pricing Module#

The Product Module doesn't provide pricing-related features.

Instead, Medusa defines a link between the ProductVariant and the PriceSet data models. A product variant’s prices are stored belonging to a price set.

A diagram showcasing an example of how data models from the Pricing and Product Module are linked.

So, to add prices for a product variant, create a price set and add the prices to it.

Retrieve with Query#

To retrieve the price set of a variant with Query, pass price_set.* in fields:

To manage the price set of a variant, use Link:


Sales Channel Module#

The Sales Channel Module provides functionalities to manage multiple selling channels in your store.

Medusa defines a link between the Product and SalesChannel data models. A product can have different availability in different sales channels.

A diagram showcasing an example of how data models from the Product and Sales Channel modules are linked.

Retrieve with Query#

To retrieve the sales channels of a product with Query, pass sales_channels.* in fields:

To manage the sales channels of a product, use Link:

Was this page helpful?
Ask Anything
Ask any questions about Medusa. Get help with your development.
You can also use the Medusa MCP server in Cursor, VSCode, etc...
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break