listAndCountPriceSetMoneyAmountRules - Pricing Module Reference
BetaThis documentation provides a reference to the listAndCountPriceSetMoneyAmountRules
method. This belongs to the Pricing Module.
This method is used to retrieve a paginated list of price set money amount rules along with the total count of available price set money amount rules 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 retrievePriceSetMoneyAmountRules (id: string) {
const pricingService = await initializePricingModule()
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
id: [id]
})
// do something with the price set money amount rules or return them
}
To specify relations that should be retrieved within the price set money amount rules:
import {
initialize as initializePricingModule,
} from "@medusajs/pricing"
async function retrievePriceSetMoneyAmountRules (id: string) {
const pricingService = await initializePricingModule()
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
id: [id]
}, {
relations: ["price_set_money_amount"],
})
// do something with the price set money amount rules 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 retrievePriceSetMoneyAmountRules (id: string, skip: number, take: number) {
const pricingService = await initializePricingModule()
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
id: [id]
}, {
relations: ["price_set_money_amount"],
skip,
take
})
// do something with the price set money amount rules 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 retrievePriceSetMoneyAmountRules (ids: string[], ruleTypeId: string[], skip: number, take: number) {
const pricingService = await initializePricingModule()
const [priceSetMoneyAmountRules, count] = await pricingService.listAndCountPriceSetMoneyAmountRules({
$and: [
{
id: ids
},
{
rule_type_id: ruleTypeId
}
]
}, {
relations: ["price_set_money_amount"],
skip,
take
})
// do something with the price set money amount rules or return them
}
Parameters
The filters to apply on the retrieved price set money amount rules.
The configurations determining how the price set money amount rules are retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a price set money amount rule.
select
or relations
, accept the
attributes or relations associated with a price set money amount rule.sharedContext
ContextA context used to share resources, such as transaction manager, between the application and the module.
sharedContext
ContextReturns
The list of price set money amount rules and their total count.
Was this section helpful?