Skip to main content
Skip to main content

IProductModuleService

internal.ProductTypes.IProductModuleService

Methods

create

create(data, sharedContext?): Promise<ProductDTO[]>

This method is used to create a product.

Example

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

async function createProduct (title: string) {
const productModule = await initializeProductModule()

const products = await productModule.create([
{
title
}
])

// do something with the products or return them
}

Parameters

dataCreateProductDTO[]Required
The products to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductDTO[]>

PromisePromise<ProductDTO[]>Required
The list of created products.

createCategory

createCategory(data, sharedContext?): Promise<ProductCategoryDTO>

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

Promise<ProductCategoryDTO>

PromisePromise<ProductCategoryDTO>Required
The created product category.

createCollections

createCollections(data, sharedContext?): Promise<ProductCollectionDTO[]>

This method is used to create product collections.

Example

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

async function createCollection (title: string) {
const productModule = await initializeProductModule()

const collections = await productModule.createCollections([
{
title
}
])

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

Parameters

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

Returns

Promise<ProductCollectionDTO[]>

PromisePromise<ProductCollectionDTO[]>Required
The list of created product collections.

createOptions

createOptions(data, sharedContext?): Promise<ProductOptionDTO[]>

This method is used to create product options.

Example

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

async function createProductOption (title: string, productId: string) {
const productModule = await initializeProductModule()

const productOptions = await productModule.createOptions([
{
title,
product_id: productId
}
])

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

Parameters

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

Returns

Promise<ProductOptionDTO[]>

PromisePromise<ProductOptionDTO[]>Required
The list of created product options.

createTags

createTags(data, sharedContext?): Promise<ProductTagDTO[]>

This method is used to create product tags.

Example

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

async function createProductTags (values: string[]) {
const productModule = await initializeProductModule()

const productTags = await productModule.createTags(
values.map((value) => ({
value
}))
)

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

Parameters

dataCreateProductTagDTO[]Required
The product tags to create.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTagDTO[]>

PromisePromise<ProductTagDTO[]>Required
The list of product tags.

createTypes

createTypes(data, sharedContext?): Promise<ProductTypeDTO[]>

This method is used to create a product type.

Example

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

async function createProductType (value: string) {
const productModule = await initializeProductModule()

const productTypes = await productModule.createTypes([
{
value
}
])

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

Parameters

dataCreateProductTypeDTO[]Required
The product types to be created.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTypeDTO[]>

PromisePromise<ProductTypeDTO[]>Required
The list of created product types.

delete

delete(productIds, sharedContext?): Promise<void>

This method is used to delete products. Unlike the softDelete method, this method will completely remove the products and they can no longer be accessed or retrieved.

Example

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

async function deleteProducts (ids: string[]) {
const productModule = await initializeProductModule()

await productModule.delete(ids)
}

Parameters

productIdsstring[]Required
The IDs of the products to be deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the products are successfully deleted.

deleteCategory

deleteCategory(categoryId, sharedContext?): Promise<void>

This method is used to delete a product category by its ID.

Example

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

async function deleteCategory (id: string) {
const productModule = await initializeProductModule()

await productModule.deleteCategory(id)
}

Parameters

categoryIdstringRequired
The ID of the product category to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the product category is successfully deleted.

deleteCollections

deleteCollections(productCollectionIds, sharedContext?): Promise<void>

This method is used to delete collections by their ID.

Example

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

async function deleteCollection (ids: string[]) {
const productModule = await initializeProductModule()

await productModule.deleteCollections(ids)
}

Parameters

productCollectionIdsstring[]Required
The IDs of the product collections to be updated.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the product options are successfully deleted.

deleteOptions

deleteOptions(productOptionIds, sharedContext?): Promise<void>

This method is used to delete a product option.

Example

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

async function deleteProductOptions (ids: string[]) {
const productModule = await initializeProductModule()

await productModule.deleteOptions(ids)
}

Parameters

productOptionIdsstring[]Required
The IDs of the product options to delete.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the product options are successfully deleted.

deleteTags

deleteTags(productTagIds, sharedContext?): Promise<void>

This method is used to delete product tags by their ID.

Example

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

async function deleteProductTags (ids: string[]) {
const productModule = await initializeProductModule()

await productModule.deleteTags(ids)

}

Parameters

productTagIdsstring[]Required
The IDs of the product tags to be deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the product tags are successfully deleted.

deleteTypes

deleteTypes(productTypeIds, sharedContext?): Promise<void>

This method is used to delete a product type.

Example

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

async function deleteProductTypes (ids: string[]) {
const productModule = await initializeProductModule()

await productModule.deleteTypes(ids)
}

Parameters

productTypeIdsstring[]Required
The IDs of the product types to be deleted.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void>

PromisePromise<void>Required
Resolves when the product types are successfully deleted.

list

list(filters?, config?, sharedContext?): Promise<ProductDTO[]>

This method is used to retrieve a paginated list of price sets based on optional filters and configuration.

Example

To retrieve a list of products using their IDs:

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

async function retrieveProducts (ids: string[]) {
const productModule = await initializeProductModule()

const products = await productModule.list({
id: ids
})

// do something with the products or return them
}

To specify relations that should be retrieved within the products:

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

async function retrieveProducts (ids: string[]) {
const productModule = await initializeProductModule()

const products = await productModule.list({
id: ids
}, {
relations: ["categories"]
})

// do something with the products or return them
}

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProducts (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const products = await productModule.list({
id: ids
}, {
relations: ["categories"],
skip,
take
})

// do something with the products or return them
}

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProducts (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const products = await productModule.list({
$and: [
{
id: ids
},
{
q: title
}
]
}, {
relations: ["categories"],
skip,
take
})

// do something with the products or return them
}

Parameters

The filters to apply on the retrieved products.
The configurations determining how the products are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductDTO[]>

PromisePromise<ProductDTO[]>Required
The list of products.

listAndCount

listAndCount(filters?, config?, sharedContext?): Promise<[ProductDTO[], number]>

This method is used to retrieve a paginated list of products along with the total count of available products satisfying the provided filters.

Example

To retrieve a list of products using their IDs:

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

async function retrieveProducts (ids: string[]) {
const productModule = await initializeProductModule()

const [products, count] = await productModule.listAndCount({
id: ids
})

// do something with the products or return them
}

To specify relations that should be retrieved within the products:

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

async function retrieveProducts (ids: string[]) {
const productModule = await initializeProductModule()

const [products, count] = await productModule.listAndCount({
id: ids
}, {
relations: ["categories"]
})

// do something with the products or return them
}

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProducts (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [products, count] = await productModule.listAndCount({
id: ids
}, {
relations: ["categories"],
skip,
take
})

// do something with the products or return them
}

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProducts (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [products, count] = await productModule.listAndCount({
$and: [
{
id: ids
},
{
q: title
}
]
}, {
relations: ["categories"],
skip,
take
})

// do something with the products or return them
}

Parameters

The filters to apply on the retrieved products.
The configurations determining how the products are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductDTO[], number]>

PromisePromise<[ProductDTO[], number]>Required
The list of products along with the total count.

listAndCountCategories

listAndCountCategories(filters?, config?, sharedContext?): Promise<[ProductCategoryDTO[], number]>

This method is used to retrieve a paginated list of product categories along with the total count of available product categories satisfying the provided filters.

Example

To retrieve a list of product categories using their IDs:

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

async function retrieveCategories (ids: string[]) {
const productModule = await initializeProductModule()

const [categories, count] = await productModule.listAndCountCategories({
id: ids
})

// do something with the product category or return it
}

To specify relations that should be retrieved within the product categories:

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

async function retrieveCategories (ids: string[]) {
const productModule = await initializeProductModule()

const [categories, count] = await productModule.listAndCountCategories({
id: ids
}, {
relations: ["parent_category"]
})

// do something with the product category or return it
}

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveCategories (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [categories, count] = await productModule.listAndCountCategories({
id: ids
}, {
relations: ["parent_category"],
skip,
take
})

// do something with the product category or return it
}

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveCategories (ids: string[], name: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [categories, count] = await productModule.listAndCountCategories({
$or: [
{
id: ids
},
{
name
}
]
}, {
relations: ["parent_category"],
skip,
take
})

// do something with the product category or return it
}

Parameters

The filters to apply on the retrieved product categories.
The configurations determining how the product categories are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product category.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductCategoryDTO[], number]>

PromisePromise<[ProductCategoryDTO[], number]>Required
The list of product categories along with their total count.

listAndCountCollections

listAndCountCollections(filters?, config?, sharedContext?): Promise<[ProductCollectionDTO[], number]>

This method is used to retrieve a paginated list of product collections along with the total count of available product collections satisfying the provided filters.

Example

To retrieve a list of product collections using their IDs:

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

async function retrieveCollections (ids: string[]) {
const productModule = await initializeProductModule()

const [collections, count] = await productModule.listAndCountCollections({
id: ids
})

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

To specify relations that should be retrieved within the product collections:

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

async function retrieveCollections (ids: string[]) {
const productModule = await initializeProductModule()

const [collections, count] = await productModule.listAndCountCollections({
id: ids
}, {
relations: ["products"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveCollections (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [collections, count] = await productModule.listAndCountCollections({
id: ids
}, {
relations: ["products"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveCollections (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [collections, count] = await productModule.listAndCountCollections({
$and: [
{
id: ids
},
{
title
}
]
}, {
relations: ["products"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product collections.
The configurations determining how the product collections are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product collection.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductCollectionDTO[], number]>

PromisePromise<[ProductCollectionDTO[], number]>Required
The list of product collections along with the total count.

listAndCountOptions

listAndCountOptions(filters?, config?, sharedContext?): Promise<[ProductOptionDTO[], number]>

This method is used to retrieve a paginated list of product options along with the total count of available product options satisfying the provided filters.

Example

To retrieve a list of product options using their IDs:

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

async function retrieveProductOptions (ids: string[]) {
const productModule = await initializeProductModule()

const [productOptions, count] = await productModule.listAndCountOptions({
id: ids
})

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

To specify relations that should be retrieved within the product types:

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

async function retrieveProductOptions (ids: string[]) {
const productModule = await initializeProductModule()

const [productOptions, count] = await productModule.listAndCountOptions({
id: ids
}, {
relations: ["product"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductOptions (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [productOptions, count] = await productModule.listAndCountOptions({
id: ids
}, {
relations: ["product"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductOptions (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [productOptions, count] = await productModule.listAndCountOptions({
$and: [
{
id: ids
},
{
title
}
]
}, {
relations: ["product"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product options.
The configurations determining how the product options are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product option.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductOptionDTO[], number]>

PromisePromise<[ProductOptionDTO[], number]>Required
The list of product options along with the total count.

listAndCountTags

listAndCountTags(filters?, config?, sharedContext?): Promise<[ProductTagDTO[], number]>

This method is used to retrieve a paginated list of product tags along with the total count of available product tags satisfying the provided filters.

Example

To retrieve a list of product tags using their IDs:

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

async function retrieveProductTag (tagIds: string[]) {
const productModule = await initializeProductModule()

const [productTags, count] = await productModule.listAndCountTags({
id: tagIds
})

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

To specify relations that should be retrieved within the product tags:

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

async function retrieveProductTag (tagIds: string[]) {
const productModule = await initializeProductModule()

const [productTags, count] = await productModule.listAndCountTags({
id: tagIds
}, {
relations: ["products"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductTag (tagIds: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [productTags, count] = await productModule.listAndCountTags({
id: tagIds
}, {
relations: ["products"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductTag (tagIds: string[], value: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [productTags, count] = await productModule.listAndCountTags({
$and: [
{
id: tagIds
},
{
value
}
]
}, {
relations: ["products"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product tags.
The configurations determining how the product tags are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product tag.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductTagDTO[], number]>

PromisePromise<[ProductTagDTO[], number]>Required
The list of product tags along with the total count.

listAndCountTypes

listAndCountTypes(filters?, config?, sharedContext?): Promise<[ProductTypeDTO[], number]>

This method is used to retrieve a paginated list of product types along with the total count of available product types satisfying the provided filters.

Example

To retrieve a list of product types using their IDs:

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

async function retrieveProductTypes (ids: string[]) {
const productModule = await initializeProductModule()

const [productTypes, count] = await productModule.listAndCountTypes({
id: ids
})

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

To specify attributes that should be retrieved within the product types:

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

async function retrieveProductTypes (ids: string[]) {
const productModule = await initializeProductModule()

const [productTypes, count] = await productModule.listAndCountTypes({
id: ids
}, {
select: ["value"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductTypes (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [productTypes, count] = await productModule.listAndCountTypes({
id: ids
}, {
select: ["value"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductTypes (ids: string[], value: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [productTypes, count] = await productModule.listAndCountTypes({
$and: [
{
id: ids
},
{
value
}
]
}, {
select: ["value"],
skip,
take
})

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

Parameters

The filters to be applied on the retrieved product type.
The configurations determining how the product types are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductTypeDTO[], number]>

PromisePromise<[ProductTypeDTO[], number]>Required
The list of product types along with their total count.

listAndCountVariants

listAndCountVariants(filters?, config?, sharedContext?): Promise<[ProductVariantDTO[], number]>

This method is used to retrieve a paginated list of product variants along with the total count of available product variants satisfying the provided filters.

Example

To retrieve a list of product variants using their IDs:

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

async function retrieveProductVariants (ids: string[]) {
const productModule = await initializeProductModule()

const [variants, count] = await productModule.listAndCountVariants({
id: ids
})

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

To specify relations that should be retrieved within the product variants:

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

async function retrieveProductVariants (ids: string[]) {
const productModule = await initializeProductModule()

const [variants, count] = await productModule.listAndCountVariants({
id: ids
}, {
relations: ["options"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductVariants (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const [variants, count] = await productModule.listAndCountVariants({
id: ids
}, {
relations: ["options"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductVariants (ids: string[], sku: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const [variants, count] = await productModule.listAndCountVariants({
$and: [
{
id: ids
},
{
sku
}
]
}, {
relations: ["options"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product variants.
The configurations determining how the product variants are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product variant.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<[ProductVariantDTO[], number]>

PromisePromise<[ProductVariantDTO[], number]>Required
The list of product variants along with their total count.

listCategories

listCategories(filters?, config?, sharedContext?): Promise<ProductCategoryDTO[]>

This method is used to retrieve a paginated list of product categories based on optional filters and configuration.

Example

To retrieve a list of product categories using their IDs:

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

async function retrieveCategories (ids: string[]) {
const productModule = await initializeProductModule()

const categories = await productModule.listCategories({
id: ids
})

// do something with the product category or return it
}

To specify relations that should be retrieved within the product categories:

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

async function retrieveCategories (ids: string[]) {
const productModule = await initializeProductModule()

const categories = await productModule.listCategories({
id: ids
}, {
relations: ["parent_category"]
})

// do something with the product category or return it
}

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveCategories (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const categories = await productModule.listCategories({
id: ids
}, {
relations: ["parent_category"],
skip,
take
})

// do something with the product category or return it
}

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveCategories (ids: string[], name: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const categories = await productModule.listCategories({
$or: [
{
id: ids
},
{
name
}
]
}, {
relations: ["parent_category"],
skip,
take
})

// do something with the product category or return it
}

Parameters

The filters to be applied on the retrieved product categories.
The configurations determining how the product categories are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product category.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCategoryDTO[]>

PromisePromise<ProductCategoryDTO[]>Required
The list of product categories.

listCollections

listCollections(filters?, config?, sharedContext?): Promise<ProductCollectionDTO[]>

This method is used to retrieve a paginated list of product collections based on optional filters and configuration.

Example

To retrieve a list of product collections using their IDs:

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

async function retrieveCollections (ids: string[]) {
const productModule = await initializeProductModule()

const collections = await productModule.listCollections({
id: ids
})

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

To specify relations that should be retrieved within the product collections:

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

async function retrieveCollections (ids: string[]) {
const productModule = await initializeProductModule()

const collections = await productModule.listCollections({
id: ids
}, {
relations: ["products"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveCollections (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const collections = await productModule.listCollections({
id: ids
}, {
relations: ["products"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveCollections (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const collections = await productModule.listCollections({
$and: [
{
id: ids
},
{
title
}
]
}, {
relations: ["products"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product collections.
The configurations determining how the product collections are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product collection.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCollectionDTO[]>

PromisePromise<ProductCollectionDTO[]>Required
The list of product collections.

listOptions

listOptions(filters?, config?, sharedContext?): Promise<ProductOptionDTO[]>

This method is used to retrieve a paginated list of product options based on optional filters and configuration.

Example

To retrieve a list of product options using their IDs:

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

async function retrieveProductOptions (ids: string[]) {
const productModule = await initializeProductModule()

const productOptions = await productModule.listOptions({
id: ids
})

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

To specify relations that should be retrieved within the product types:

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

async function retrieveProductOptions (ids: string[]) {
const productModule = await initializeProductModule()

const productOptions = await productModule.listOptions({
id: ids
}, {
relations: ["product"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductOptions (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const productOptions = await productModule.listOptions({
id: ids
}, {
relations: ["product"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductOptions (ids: string[], title: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const productOptions = await productModule.listOptions({
$and: [
{
id: ids
},
{
title
}
]
}, {
relations: ["product"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product options.
The configurations determining how the product options are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product option.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductOptionDTO[]>

PromisePromise<ProductOptionDTO[]>Required
The list of product options.

listTags

listTags(filters?, config?, sharedContext?): Promise<ProductTagDTO[]>

This method is used to retrieve a paginated list of tags based on optional filters and configuration.

Example

To retrieve a list of product tags using their IDs:

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

async function retrieveProductTag (tagIds: string[]) {
const productModule = await initializeProductModule()

const productTags = await productModule.listTags({
id: tagIds
})

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

To specify relations that should be retrieved within the product tags:

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

async function retrieveProductTag (tagIds: string[]) {
const productModule = await initializeProductModule()

const productTags = await productModule.listTags({
id: tagIds
}, {
relations: ["products"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductTag (tagIds: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const productTags = await productModule.listTags({
id: tagIds
}, {
relations: ["products"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductTag (tagIds: string[], value: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const productTags = await productModule.listTags({
$and: [
{
id: tagIds
},
{
value
}
]
}, {
relations: ["products"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product tags.
The configurations determining how the product tags are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product tag.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTagDTO[]>

PromisePromise<ProductTagDTO[]>Required
The list of product tags.

listTypes

listTypes(filters?, config?, sharedContext?): Promise<ProductTypeDTO[]>

This method is used to retrieve a paginated list of product types based on optional filters and configuration.

Example

To retrieve a list of product types using their IDs:

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

async function retrieveProductTypes (ids: string[]) {
const productModule = await initializeProductModule()

const productTypes = await productModule.listTypes({
id: ids
})

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

To specify attributes that should be retrieved within the product types:

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

async function retrieveProductTypes (ids: string[]) {
const productModule = await initializeProductModule()

const productTypes = await productModule.listTypes({
id: ids
}, {
select: ["value"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductTypes (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const productTypes = await productModule.listTypes({
id: ids
}, {
select: ["value"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductTypes (ids: string[], value: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const productTypes = await productModule.listTypes({
$and: [
{
id: ids
},
{
value
}
]
}, {
select: ["value"],
skip,
take
})

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

Parameters

The filters to apply on the retrieved product types.
The configurations determining how the product types are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTypeDTO[]>

PromisePromise<ProductTypeDTO[]>Required
The list of product types.

listVariants

listVariants(filters?, config?, sharedContext?): Promise<ProductVariantDTO[]>

This method is used to retrieve a paginated list of product variants based on optional filters and configuration.

Example

To retrieve a list of product variants using their IDs:

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

async function retrieveProductVariants (ids: string[]) {
const productModule = await initializeProductModule()

const variants = await productModule.listVariants({
id: ids
})

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

To specify relations that should be retrieved within the product variants:

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

async function retrieveProductVariants (ids: string[]) {
const productModule = await initializeProductModule()

const variants = await productModule.listVariants({
id: ids
}, {
relations: ["options"]
})

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

By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:

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

async function retrieveProductVariants (ids: string[], skip: number, take: number) {
const productModule = await initializeProductModule()

const variants = await productModule.listVariants({
id: ids
}, {
relations: ["options"],
skip,
take
})

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

You can also use the $and or $or properties of the filter parameter to use and/or conditions in your filters. For example:

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

async function retrieveProductVariants (ids: string[], sku: string, skip: number, take: number) {
const productModule = await initializeProductModule()

const variants = await productModule.listVariants({
$and: [
{
id: ids
},
{
sku
}
]
}, {
relations: ["options"],
skip,
take
})

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

Parameters

The filters applied on the retrieved product variants.
The configurations determining how the product variants are retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product variant.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductVariantDTO[]>

PromisePromise<ProductVariantDTO[]>Required
The list of product variants.

restore

restore<TReturnableLinkableKeys>(productIds, config?, sharedContext?): Promise<void | Record<string, string[]>>

This method is used to restore products which were deleted using the softDelete method.

TReturnableLinkableKeysstringRequired

Example

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

async function restoreProducts (ids: string[]) {
const productModule = await initializeProductModule()

const cascadedEntities = await productModule.restore(ids, {
returnLinkableKeys: ["variant_id"]
})

// do something with the returned cascaded entity IDs or return them
}

Parameters

productIdsstring[]Required
The IDs of the products to restore.
configRestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with the each of the products. You can pass to its returnLinkableKeys property any of the product's relation attribute names, such as variant_id.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void | Record<string, string[]>>

PromisePromise<void | Record<string, string[]>>Required
An object that includes the IDs of related records that were restored, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as variant_id, and its value is an array of strings, each being the ID of the record associated with the product through this relation, such as the IDs of associated product variants. If there are no related records that were restored, the promise resolved to void.

restoreVariants

restoreVariants<TReturnableLinkableKeys>(variantIds, config?, sharedContext?): Promise<void | Record<string, string[]>>

TReturnableLinkableKeysstringRequired

Parameters

variantIdsstring[]Required
configRestoreReturn<TReturnableLinkableKeys>
sharedContextContext

Returns

Promise<void | Record<string, string[]>>

PromisePromise<void | Record<string, string[]>>Required

retrieve

retrieve(productId, config?, sharedContext?): Promise<ProductDTO>

This method is used to retrieve a product by its ID

Example

A simple example that retrieves a product by its ID:

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

async function retrieveProduct (id: string) {
const productModule = await initializeProductModule()

const product = await productModule.retrieve(id)

// do something with the product or return it
}

To specify relations that should be retrieved:

import {
initialize as initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSet (priceSetId: string) {
const pricingService = await initializePricingModule()

const priceSet = await pricingService.retrieve(
priceSetId,
{
relations: ["money_amounts"]
}
)

// do something with the price set or return it
}

Parameters

productIdstringRequired
The ID of the product to retrieve.
The configurations determining how the product is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductDTO>

PromisePromise<ProductDTO>Required
The retrieved product.

retrieveCategory

retrieveCategory(productCategoryId, config?, sharedContext?): Promise<ProductCategoryDTO>

This method is used to retrieve a product category by its ID.

Example

A simple example that retrieves a product category by its ID:

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

async function retrieveCategory (id: string) {
const productModule = await initializeProductModule()

const category = await productModule.retrieveCategory(id)

// do something with the product category or return it
}

To specify relations that should be retrieved:

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

async function retrieveCategory (id: string) {
const productModule = await initializeProductModule()

const category = await productModule.retrieveCategory(id, {
relations: ["parent_category"]
})

// do something with the product category or return it
}

Parameters

productCategoryIdstringRequired
The ID of the product category to retrieve.
The configurations determining how the product category is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product category.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCategoryDTO>

PromisePromise<ProductCategoryDTO>Required
The retrieved product category.

retrieveCollection

retrieveCollection(productCollectionId, config?, sharedContext?): Promise<ProductCollectionDTO>

This method is used to retrieve a product collection by its ID.

Example

A simple example that retrieves a product collection by its ID:

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

async function retrieveCollection (id: string) {
const productModule = await initializeProductModule()

const collection = await productModule.retrieveCollection(id)

// do something with the product collection or return it
}

To specify relations that should be retrieved:

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

async function retrieveCollection (id: string) {
const productModule = await initializeProductModule()

const collection = await productModule.retrieveCollection(id, {
relations: ["products"]
})

// do something with the product collection or return it
}

Parameters

productCollectionIdstringRequired
The ID of the product collection to retrieve.
The configurations determining how the product collection is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product collection.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCollectionDTO>

PromisePromise<ProductCollectionDTO>Required
The retrieved product collection.

retrieveOption

retrieveOption(optionId, config?, sharedContext?): Promise<ProductOptionDTO>

This method is used to retrieve a product option by its ID.

Example

A simple example that retrieves a product option by its ID:

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

async function retrieveProductOption (id: string) {
const productModule = await initializeProductModule()

const productOption = await productModule.retrieveOption(id)

// do something with the product option or return it
}

To specify relations that should be retrieved:

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

async function retrieveProductOption (id: string) {
const productModule = await initializeProductModule()

const productOption = await productModule.retrieveOption(id, {
relations: ["product"]
})

// do something with the product option or return it
}

Parameters

optionIdstringRequired
The ID of the product option to retrieve.
The configurations determining how the product option is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product option.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductOptionDTO>

PromisePromise<ProductOptionDTO>Required
The retrieved product option.

retrieveTag

retrieveTag(tagId, config?, sharedContext?): Promise<ProductTagDTO>

This method is used to retrieve a tag by its ID.

Example

A simple example that retrieves a product tag by its ID:

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

async function retrieveProductTag (tagId: string) {
const productModule = await initializeProductModule()

const productTag = await productModule.retrieveTag(tagId)

// do something with the product tag or return it
}

To specify relations that should be retrieved:

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

async function retrieveProductTag (tagId: string) {
const productModule = await initializeProductModule()

const productTag = await productModule.retrieveTag(tagId, {
relations: ["products"]
})

// do something with the product tag or return it
}

Parameters

tagIdstringRequired
The ID of the tag to retrieve.
The configurations determining how the product tag is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product tag.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTagDTO>

PromisePromise<ProductTagDTO>Required
The retrieved product tag.

retrieveType

retrieveType(typeId, config?, sharedContext?): Promise<ProductTypeDTO>

This method is used to retrieve a product type by its ID.

Example

A simple example that retrieves a product type by its ID:

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

async function retrieveProductType (id: string) {
const productModule = await initializeProductModule()

const productType = await productModule.retrieveType(id)

// do something with the product type or return it
}

To specify attributes that should be retrieved:

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

async function retrieveProductType (id: string) {
const productModule = await initializeProductModule()

const productType = await productModule.retrieveType(id, {
select: ["value"]
})

// do something with the product type or return it
}

Parameters

typeIdstringRequired
The ID of the product type to retrieve.
The configurations determining how the product type is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTypeDTO>

PromisePromise<ProductTypeDTO>Required
The retrieved product type.

retrieveVariant

retrieveVariant(productVariantId, config?, sharedContext?): Promise<ProductVariantDTO>

This method is used to retrieve a product variant by its ID.

Example

A simple example that retrieves a product variant by its ID:

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

async function retrieveProductVariant (id: string) {
const productModule = await initializeProductModule()

const variant = await productModule.retrieveVariant(id)

// do something with the product variant or return it
}

To specify relations that should be retrieved:

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

async function retrieveProductVariant (id: string) {
const productModule = await initializeProductModule()

const variant = await productModule.retrieveVariant(id, {
relations: ["options"]
})

// do something with the product variant or return it
}

Parameters

productVariantIdstringRequired
The ID of the product variant to retrieve.
The configurations determining how the product variant is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a product variant.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductVariantDTO>

PromisePromise<ProductVariantDTO>Required
The retrieved product variant.

softDelete

softDelete<TReturnableLinkableKeys>(productIds, config?, sharedContext?): Promise<void | Record<string, string[]>>

This method is used to delete products. Unlike the delete method, this method won't completely remove the product. It can still be accessed or retrieved using methods like retrieve if you pass the withDeleted property to the config object parameter.

The soft-deleted products can be restored using the restore method.

TReturnableLinkableKeysstringRequired

Example

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

async function deleteProducts (ids: string[]) {
const productModule = await initializeProductModule()

const cascadedEntities = await productModule.softDelete(ids)

// do something with the returned cascaded entity IDs or return them
}

Parameters

productIdsstring[]Required
The IDs of the products to soft-delete.
configSoftDeleteReturn<TReturnableLinkableKeys>
Configurations determining which relations to soft delete along with the each of the products. You can pass to its returnLinkableKeys property any of the product's relation attribute names, such as variant_id.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<void | Record<string, string[]>>

PromisePromise<void | Record<string, string[]>>Required
An object that includes the IDs of related records that were also soft deleted, such as the ID of associated product variants. The object's keys are the ID attribute names of the product entity's relations, such as variant_id, and its value is an array of strings, each being the ID of a record associated with the product through this relation, such as the IDs of associated product variants. If there are no related records, the promise resolved to void.

update

update(data, sharedContext?): Promise<ProductDTO[]>

This method is used to update a product.

Example

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

async function updateProduct (id: string, title: string) {
const productModule = await initializeProductModule()

const products = await productModule.update([
{
id,
title
}
])

// do something with the products or return them
}

Parameters

dataUpdateProductDTO[]Required
The products to be updated, each holding the attributes that should be updated in the product.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductDTO[]>

PromisePromise<ProductDTO[]>Required
The list of updated products.

updateCategory

updateCategory(categoryId, data, sharedContext?): Promise<ProductCategoryDTO>

This method is used to update a product category by its ID.

Example

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

async function updateCategory (id: string, name: string) {
const productModule = await initializeProductModule()

const category = await productModule.updateCategory(id, {
name,
})

// do something with the product category or return it
}

Parameters

categoryIdstringRequired
The ID of the product category to update.
The attributes to update in th product category.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCategoryDTO>

PromisePromise<ProductCategoryDTO>Required
The updated product category.

updateCollections

updateCollections(data, sharedContext?): Promise<ProductCollectionDTO[]>

This method is used to update existing product collections.

Example

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

async function updateCollection (id: string, title: string) {
const productModule = await initializeProductModule()

const collections = await productModule.updateCollections([
{
id,
title
}
])

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

Parameters

The product collections to be updated, each holding the attributes that should be updated in the product collection.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductCollectionDTO[]>

PromisePromise<ProductCollectionDTO[]>Required
The list of updated product collections.

updateOptions

updateOptions(data, sharedContext?): Promise<ProductOptionDTO[]>

This method is used to update existing product options.

Example

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

async function updateProductOption (id: string, title: string) {
const productModule = await initializeProductModule()

const productOptions = await productModule.updateOptions([
{
id,
title
}
])

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

Parameters

The product options to be updated, each holding the attributes that should be updated in the product option.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductOptionDTO[]>

PromisePromise<ProductOptionDTO[]>Required
The list of updated product options.

updateTags

updateTags(data, sharedContext?): Promise<ProductTagDTO[]>

This method is used to update existing product tags.

Example

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

async function updateProductTag (id: string, value: string) {
const productModule = await initializeProductModule()

const productTags = await productModule.updateTags([
{
id,
value
}
])

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

Parameters

dataUpdateProductTagDTO[]Required
The product tags to be updated, each having the attributes that should be updated in a product tag.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTagDTO[]>

PromisePromise<ProductTagDTO[]>Required
The list of updated product tags.

updateTypes

updateTypes(data, sharedContext?): Promise<ProductTypeDTO[]>

This method is used to update a product type

Example

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

async function updateProductType (id: string, value: string) {
const productModule = await initializeProductModule()

const productTypes = await productModule.updateTypes([
{
id,
value
}
])

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

Parameters

dataUpdateProductTypeDTO[]Required
The product types to be updated, each having the attributes that should be updated in the product type.
sharedContextContext
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise<ProductTypeDTO[]>

PromisePromise<ProductTypeDTO[]>Required
The list of updated product types.
Was this section helpful?