- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
- Get Started
- Product
- Resources
- Tools & SDKs
- Framework
- Reference
3.5. Commerce Modules
In this chapter, you'll learn about Medusa's commerce modules.
What is a Commerce Module?#
Medusa provides all its commerce features as separate commerce modules, such as the Product or Order modules. Medusa uses these modules in its API routes to expose their commerce features.
Medusa's commerce modules and your custom modules are interchangeable in the Medusa application, making Medusa’s architecture more flexible.
List of Medusa's Commerce Modules#
Refer to this reference for a full list of commerce modules in Medusa.
Resolve Commerce Module Services#
Similarly to your custom module, a commerce module's main service is registered in the Medusa container. So, you can resolve it in your resources, such as API routes, to use its functionality.
For example, you saw this code snippet in the Medusa container chapter:
1import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"2import { IProductModuleService } from "@medusajs/framework/types"3import { Modules } from "@medusajs/framework/utils"4 5export const GET = async (6 req: MedusaRequest, 7 res: MedusaResponse8) => {9 const productModuleService: IProductModuleService = req.scope.resolve(10 Modules.PRODUCT11 )12 13 const [, count] = await productModuleService14 .listAndCountProducts()15 16 res.json({17 count,18 })19}
When you resolve the Modules.PRODUCT
(or productModuleService
) registration name, you're actually resolving the main service of the Product Module.