packages/core/src/links. Read across a link with query.graph and the link’s alias. Read-only links have no pivot table: they resolve from a foreign key column on one side, and you change them by updating that column.
Resolve query from the container before you run the examples:
Product and Seller
The store allowlist. A product with no rows is open to every store.- Sides:
Product(many) andSeller(many) - Storage: pivot table
product_sellerwithproduct_idandseller_id - Alias on product:
sellers - File:
product-seller-link.ts
linkSellersToProductWorkflow or the seller_ids input of createProductsWorkflow.
ProductCategory and Seller
Links stores to categories. No shipped route filters products by it.- Sides:
ProductCategory(many) andSeller(many) - Storage: pivot table generated by Medusa
- Alias on category:
sellers - File:
category-seller-link.ts
linkSellersToProductCategoryWorkflow.
Offer and Product
Each offer points at the master product it sells.- Sides:
Offer(one) toProduct(one) - Storage: read-only, through
offer.product_id - Alias on offer:
product - File:
offer-product-link.ts
offer filtered by product_id, as above.
Offer and ProductVariant
Each offer sells exactly one variant.- Sides:
Offer(one) toProductVariant(one) - Storage: read-only, through
offer.variant_id - Alias on offer:
product_variant - File:
offer-variant-link.ts
Product and ProductChange
The audit and edit history of a product, including everyPRODUCT_ADD and STATUS_CHANGE record.
- Sides:
Product(one) toProductChange(many) - Storage: read-only, through
product_change.product_id - Alias on product:
changes - File:
product-change-link.ts
Product and ProductAttributeValue
The attribute values attached to a product.- Sides:
Product(many) andProductAttributeValue(many) - Storage: pivot table
product_attribute_value_link - Alias on product:
product_attribute_values - File:
product-attribute-value-pivot-link.ts
Product and scoped ProductAttribute
Attributes created inline for one product.- Sides:
Product(one) toProductAttribute(many) - Storage: read-only, through
product_attribute.product_id - Alias on product:
scoped_attributes - File:
product-attribute-product-link.ts
ProductAttribute and ProductCategory
Assigns attributes to categories.- Sides:
ProductAttribute(many) andProductCategory(many) - Storage: pivot table
product_category_attribute - Alias on attribute:
categories - File:
product-attribute-category-link.ts
Attribute option mirrors
A variant-axis attribute mirrors a native option, and each of its values mirrors an option value. Both links are one-to-one and read-only:ProductAttributetoProductOption: throughproduct_attribute.product_option_id, inproduct-attribute-option-mirror-link.tsProductAttributeValuetoProductOptionValue: throughproduct_attribute_value.product_option_value_id, inproduct-attribute-value-option-value-mirror-link.ts
Product and Review
Customer reviews of a product.- Sides:
Product(one) toReview(many) - Storage: pivot table generated by Medusa
- Alias on product:
reviews - File:
product-review.ts
ProductCategory and ProductCollection images
Categories and collections own gallery and icon images from Mercur’s media module.- Sides:
ProductCategory(one) toMediaImage(many), andProductCollection(one) toMediaImage(many) - Alias:
media_imageson both - Files:
media-product-category-link.tsandmedia-product-collection-link.ts