Skip to main content
Skip to main content

createVariants - Product Module Reference

Beta

This documentation provides a reference to the createVariants method. This belongs to the Product Module.

This method is used to create variants for a product.

Example

import {
initialize as initializeProductModule,
} from "@medusajs/product"

async function createProductVariants (items: {
product_id: string,
title: string
}[]) {
const productModule = await initializeProductModule()

const productVariants = await productModule.createVariants(items)

// do something with the product variants or return them
}

Parameters

The product variants to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

PromisePromise<ProductVariantDTO[]>Required
The created product variants' details.
Was this section helpful?