Product Module

The Product Module 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        values: ["Black", "White"],8      },9    ],10    variants: [11      {12        title: "Black Shirt",13        options: {14          Color: "Black",15        },16      },17    ],18  },19])

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