Commerce Modules

Product Module

The Product Module is the @medusajs/medusa/product NPM package that provides product-related features in your Medusa and Node.js applications.

How to Use Product Module's Service#

You can use the Product Module's main service by resolving from the Medusa container the resource Modules.PRODUCT imported from @medusajs/framework/utils.

For example:


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.

Code
1const products = await productService.createProducts([2  {3    title: "Medusa Shirt",4    options: [5      {6        title: "Color",7      },8    ],9    variants: [10      {11        title: "Black Shirt",12        options: [13          {14            value: "Black",15          },16        ],17      },18    ],19  },20])

Product Organization#

The Product Module provides different data models used to organize products, including categories, collections, tags, and more.

Code
1const category = await productService.createProductCategories({2  name: "Shirts",3})4
5const products = await productService.updateProducts([6  {7    id: product.id,8    categories: [9      {10        id: category.id,11      },12    ],13  },14])
Was this page helpful?
Edit this page