Product Module

In this section of the documentation, you will find resources to learn more about the Product Module and how to use it in your application.

Looking for no-code docs?Refer to the Medusa Admin User Guide to learn how to manage products using the dashboard.

Medusa has product related features available out-of-the-box through the Product Module. A module is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Product Module.

NoteLearn more about why modules are isolated in this documentation.

Product Features#

  • Products Management: Store and manage products. Products have custom options, such as color or size, and each variant in the product sets the value for these options.
  • Product Organization: The Product Module provides different data models used to organize products, including categories, collections, tags, and more.
  • Bundled and Multi-Part Products: Create and manage inventory kits for a single product, allowing you to implement use cases like bundled or multi-part products.

How to Use the Product Module#

In your Medusa application, you build flows around commerce modules. A flow is built as a Workflow, which is a special function composed of a series of steps that guarantees data consistency and reliable roll-back mechanism.

You can build custom workflows and steps. You can also re-use Medusa's workflows and steps, which are provided by the @medusajs/medusa/core-flows package.

For example:

src/workflows/create-product.ts
1import { 2  createWorkflow, 3  WorkflowResponse,4  createStep,5  StepResponse,6} from "@medusajs/framework/workflows-sdk"7import { Modules } from "@medusajs/framework/utils"8
9const createProductStep = createStep(10  "create-product",11  async ({}, { container }) => {12    const productService = container.resolve(Modules.PRODUCT)13
14    const product = await productService.createProducts({15      title: "Medusa Shirt",16      options: [17        {18          title: "Color",19          values: ["Black", "White"],20        },21      ],22      variants: [23        {24          title: "Black Shirt",25          options: {26            Color: "Black",27          },28        },29      ],30    })31
32    return new StepResponse({ product }, product.id)33  },34  async (productId, { container }) => {35    if (!productId) {36      return37    }38    const productService = container.resolve(Modules.PRODUCT)39
40    await productService.deleteProducts([productId])41  }42)43
44export const createProductWorkflow = createWorkflow(45  "create-product",46  () => {47    const { product } = createProductStep()48
49    return new WorkflowResponse({50      product,51    })52  }53)

You can then execute the workflow in your custom API routes, scheduled jobs, or subscribers:

src/api/workflow/route.ts
5import { createProductWorkflow } from "../../workflows/create-product"6
7export async function GET(8  req: MedusaRequest,9  res: MedusaResponse10) {11  const { result } = await createProductWorkflow(req.scope)12    .run()13
14  res.send(result)15}

Learn more about workflows in this documentation.


Server Guides#

Learn how to use the Product Module in your customizations on the Medusa application server.

Extend Module
Get Variant Prices
Get Variant Price with Taxes
Get Variant Prices
Get Variant Price with Taxes

Storefront Guides#

Learn how to integrate the Product Module's features into your storefront.

List Product Categories in Storefront
Retrieve Nested Categories in Storefront
Retrieve a Category's Products in Storefront
Retrieve a Category in Storefront
List Product Collections in Storefront
Retrieve a Collection's Products in Storefront
Retrieve a Collection in Storefront
Retrieve Product Variant's Inventory in Storefront
List Products in Storefront
Example: Show Sale Price
Example: Show Variant's Price
Example: Show Price with Taxes
Retrieve Product Variant's Prices in Storefront
Retrieve a Product in Storefront
Select Product Variants in Storefront

References#

Find references for tools and resources related to the Product Module, such as data models, methods, and more. These are useful for your customizations.

Workflows
JS SDK
Events Reference
Admin Widget Zones
Main Service Reference
Data Models Reference
Was this page helpful?
Edited Feb 26·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