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:

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

Cart Module#

Medusa defines read-only links between:

  • The Product data model and the Cart Module's LineItem data model. This means you can retrieve the details of a line item's product, but you don't manage the links in a pivot table in the database. The product of a line item is determined by the product_id property of the LineItem data model.
  • The ProductVariant data model and the Cart Module's LineItem data model. This means you can retrieve the details of a line item's variant, but you don't manage the links in a pivot table in the database. The variant of a line item is determined by the variant_id property of the LineItem data model.

Retrieve with Query#

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

NoteTo retrieve the line items of a product, pass line_items.* in fields.

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.

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 Product data model and the Order Module's OrderLineItem data model. This means you can retrieve the details of a line item's product, but you don't manage the links in a pivot table in the database. The product of a line item is determined by the product_id property of the OrderLineItem data model.
  • the ProductVariant data model and the Order Module's OrderLineItem data model. This means you can retrieve the details of a line item's variant, but you don't manage the links in a pivot table in the database. The variant of a line item is determined by the variant_id property of the OrderLineItem data model.

Retrieve with Query#

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

NoteTo retrieve a product's order line items, pass order_items.* 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?
Edit this page
Ask Anything
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