Offer and OfferCondition rows directly. Use it in subscribers, scheduled jobs, and your own steps when you don’t need what the workflows add on top.
Resolve the service
Resolve the service from the container withMercurModules.OFFER.
Generated methods
The service extendsMedusaService({ Offer, OfferCondition }), which generates these methods for each model:
listOffers and listAndCountOffers with group_by_seller
Both offer list methods accept an extragroup_by_seller filter. Without it they behave like the generated methods.
group_by_seller: true, the service returns one offer per (product_id, seller_id) group, the newest by created_at. Each returned offer gets variant_count and offer_ids for its group, and the count is the number of groups.
Grouped mode reads only the product_id and seller_id filters. Pagination uses config.skip and config.take, with take defaulting to 20.
getStatistics
Counts offers, and the distinct stores and products behind them, as they stood at a point in time.input.at defaults to now. input.filters.seller_id takes one id or a list. An offer counts when it was created at or before at and wasn’t deleted by then.
{ offers, sellers, products }, each a number.