@medusajs/product
Documentation | Website
Building blocks for digital commerce
Product Module for Medusa: manages products, product variants, options and option values, categories, collections, tags, types, and images. Use it to build and organize a product catalog. It ships with @medusajs/medusa and is registered by default, so Medusa applications don't install it directly.
At a glance
| Package | @medusajs/product |
| Type | Commerce Module |
| Module key | Modules.PRODUCT ("product") |
| Registered by default | Yes |
| Import from | @medusajs/medusa/product |
Features
- Store products with options, such as color or size, and variants for each option combination.
- Share options across products, or keep an option exclusive to one product.
- Organize products with nested categories, collections, tags, and types.
- Attach images to products and to specific variants.
Installation
No installation needed. The module is included in @medusajs/medusa and registered by default.
Usage
Resolve the module's service from the container, for example in a workflow step:
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const createProductStep = createStep(
"create-product",
async ({}, { container }) => {
const productService = container.resolve(Modules.PRODUCT)
const product = await productService.createProducts({
title: "Medusa Shirt",
options: [
{
title: "Color",
values: ["Black", "White"],
},
],
variants: [
{
title: "Black Shirt",
options: {
Color: "Black",
},
},
],
})
return new StepResponse({ product }, product.id)
}
)