packages/core/src/links/ connect the offer to the rest of the marketplace, and query.graph follows them by alias.
Offer to store
Each offer belongs to one store. The offer row keepsseller_id for filters and the unique SKU index, and the offer_seller link table mirrors it so the Medusa index engine can join offers to stores. createOffersWorkflow writes both; set seller_id and let the workflow create the link.
Offer to product and variant
Each offer points at one master product and one master variant. The product link is a writableoffer_product table, mirrored from offer.product_id by createOffersWorkflow, so the index engine can filter offers by product status. The variant link is read-only and reads offer.variant_id.
product_variant. Use product_variant.price_set.id to reach the shared price set that holds the offer’s prices.
Offer to shipping profile
Each offer ships with one profile, read fromoffer.shipping_profile_id.
Offer to price
One offer has many prices. The link records which rows on the variant’s shared price set belong to the offer. The offer workflows create and dismiss these links, so don’t write them yourself.offer_id price rule with the offer’s id.
Offer to inventory item
Offers and inventory items link many to many. The link table isoffer_inventory_item, with an extra required_quantity integer column that defaults to 1.
The link has three aliases:
offer.inventory_items: the linkedInventoryItemrows, without pivot columnsoffer.inventory_item_link: the pivot rows, withrequired_quantityand a nestedinventory_iteminventory_item.offers: the offers that draw on an inventory item
Cart and order line items to offer
Line items link to the offer that was bought. Both links setisList: true on the line item side, so one offer can back line items in any number of carts and orders.
offer on both cart and order line items. At checkout, mirrorLineItemOfferLinksToOrderStep copies each cart line item’s link to the new order line item. A subscriber does the same for line items added later by order edits, exchanges, and claims.
Product to shipping profile
createOffersWorkflow also writes Medusa’s own product to shipping profile link when the product has none. That link is Medusa’s, not Mercur’s. See How an offer ships.