1 import { ModuleJoinerConfig } from "@medusajs/framework/types"
2 import { Modules } from "@medusajs/framework/utils"
3
4 export const OrderProduct: ModuleJoinerConfig = {
5 isLink: true,
6 isReadOnlyLink: true,
7 extends: [
8 {
9 serviceName: Modules.ORDER,
10 entity: "OrderLineItem",
11 relationship: {
12 serviceName: Modules.PRODUCT,
13 entity: "Product",
14 primaryKey: "id",
15 foreignKey: "items.product_id",
16 alias: "product",
17 args: {
18 methodSuffix: "Products",
19 },
20 },
21 },
22 {
23 serviceName: Modules.ORDER,
24 entity: "OrderLineItem",
25 relationship: {
26 serviceName: Modules.PRODUCT,
27 entity: "ProductVariant",
28 primaryKey: "id",
29 foreignKey: "items.variant_id",
30 alias: "variant",
31 args: {
32 methodSuffix: "ProductVariants",
33 },
34 },
35 },
36 {
37 serviceName: Modules.PRODUCT,
38 entity: "ProductVariant",
39 relationship: {
40 serviceName: Modules.ORDER,
41 entity: "OrderLineItem",
42 primaryKey: "variant_id",
43 foreignKey: "id",
44 alias: "order_items",
45 isList: true,
46 args: {
47 methodSuffix: "OrderLineItems",
48 },
49 },
50 },
51 ],
52 }