createCategory - Product Module Reference
BetaThis documentation provides a reference to the createCategory method. This belongs to the Product Module.
This method is used to create a product category.
Example
import {
initialize as initializeProductModule,
} from "@medusajs/product"
async function createCategory (name: string, parent_category_id: string | null) {
const productModule = await initializeProductModule()
const category = await productModule.createCategory({
name,
parent_category_id
})
// do something with the product category or return it
}
Parameters
The product category to be created.
sharedContext
ContextA context used to share resources, such as transaction manager, between the application and the module.
sharedContext
ContextReturns
The created product category.
Was this section helpful?