feat: Add Sales Channel Stock Location link (#6634)

This commit is contained in:
Oli Juhl
2024-03-08 15:26:26 +01:00
committed by GitHub
parent a92cdeb01d
commit 4136b9da5f
7 changed files with 202 additions and 6 deletions

View File

@@ -11,4 +11,5 @@ export * from "./product-variant-inventory-item"
export * from "./product-variant-price-set"
export * from "./publishable-api-key-sales-channel"
export * from "./region-payment-provider"
export * from "./sales-channel-location"

View File

@@ -0,0 +1,63 @@
import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS } from "../links"
export const SalesChannelLocation: ModuleJoinerConfig = {
serviceName: LINKS.SalesChannelLocation,
isLink: true,
databaseConfig: {
tableName: "sales_channel_locations",
idPrefix: "scloc",
},
alias: [
{
name: ["sales_channel_location", "sales_channel_locations"],
args: {
entity: "LinkSalesChannelLocation",
},
},
],
primaryKeys: ["id", "sales_channel_id", "location_id"],
relationships: [
{
serviceName: Modules.SALES_CHANNEL,
primaryKey: "id",
foreignKey: "sales_channel_id",
alias: "sales_channel",
},
{
serviceName: Modules.STOCK_LOCATION,
primaryKey: "id",
foreignKey: "location_id",
alias: "location",
},
],
extends: [
{
serviceName: Modules.SALES_CHANNEL,
fieldAlias: {
locations: "locations_link.location",
},
relationship: {
serviceName: LINKS.SalesChannelLocation,
primaryKey: "sales_channel_id",
foreignKey: "id",
alias: "locations_link",
isList: true,
},
},
{
serviceName: Modules.STOCK_LOCATION,
fieldAlias: {
sales_channels: "sales_channels_link.sales_channel",
},
relationship: {
serviceName: LINKS.SalesChannelLocation,
primaryKey: "location_id",
foreignKey: "id",
alias: "sales_channels_link",
isList: true,
},
},
],
}

View File

@@ -32,6 +32,12 @@ export const LINKS = {
Modules.PROMOTION,
"promotion_id"
),
SalesChannelLocation: composeLinkName(
Modules.SALES_CHANNEL,
"sales_channel_id",
Modules.STOCK_LOCATION,
"location_id"
),
// Internal services
ProductShippingProfile: composeLinkName(