Skip to main content
Skip to main content

retrieveOption - Product Module Reference

Beta

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

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

PromisePromise<ProductOptionDTO>Required
The retrieved product option.
Was this section helpful?