Skip to main content
Skip to main content

retrieveCollection - Product Module Reference

Beta

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

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

PromisePromise<ProductCollectionDTO>Required
The retrieved product collection.
Was this section helpful?