Skip to main content
Skip to main content

createCategory - Product Module Reference

Beta

This 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.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<ProductCategoryDTO>Required
The created product category.
Was this section helpful?