Skip to main content
Skip to main content

listAndCountPriceSetMoneyAmounts - Pricing Module Reference

Beta

This documentation provides a reference to the listAndCountPriceSetMoneyAmounts method. This belongs to the Pricing Module.

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

Example

To retrieve a list of price set money amounts using their IDs:

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

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
})

// do something with the price set money amounts or return them
}

To specify relations that should be retrieved within the price set money amounts:

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

async function retrievePriceSetMoneyAmounts (id: string) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"],
})

// do something with the price set money amounts 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 initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (id: string, skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
id: [id]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set money amounts 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 initializePricingModule,
} from "@medusajs/pricing"

async function retrievePriceSetMoneyAmounts (ids: string[], titles: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()

const [priceSetMoneyAmounts, count] = await pricingService.listAndCountPriceSetMoneyAmounts({
$and: [
{
id: ids
},
{
title: titles
}
]
}, {
relations: ["price_rules"],
skip,
take
})

// do something with the price set money amounts or return them
}

Parameters

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

Returns

PromisePromise<[PriceSetMoneyAmountDTO[], number]>Required
The list of price set money amounts and their total count.
Was this section helpful?