From 171434e4d121ba4dfba1667d2455392c19dc9cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frane=20Poli=C4=87?= <16856471+fPolic@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:05:18 +0200 Subject: [PATCH] fix: allow to pass external_id on create/update (#9694) --- packages/core/types/src/http/product/admin/payloads.ts | 2 ++ packages/core/types/src/product/common.ts | 8 ++++++++ packages/medusa/src/api/admin/products/validators.ts | 2 ++ 3 files changed, 12 insertions(+) diff --git a/packages/core/types/src/http/product/admin/payloads.ts b/packages/core/types/src/http/product/admin/payloads.ts index 35739f8179..c976542ef6 100644 --- a/packages/core/types/src/http/product/admin/payloads.ts +++ b/packages/core/types/src/http/product/admin/payloads.ts @@ -69,6 +69,7 @@ export interface AdminCreateProduct { handle?: string status?: ProductStatus type_id?: string + external_id?: string collection_id?: string categories?: { id: string }[] tags?: { id: string }[] @@ -119,6 +120,7 @@ export interface AdminUpdateProduct { handle?: string status?: ProductStatus type_id?: string | null + external_id?: string | null collection_id?: string | null categories?: { id: string }[] tags?: { id: string }[] diff --git a/packages/core/types/src/product/common.ts b/packages/core/types/src/product/common.ts index e419d18b77..9c43e90b8a 100644 --- a/packages/core/types/src/product/common.ts +++ b/packages/core/types/src/product/common.ts @@ -1453,6 +1453,10 @@ export interface CreateProductDTO { * The associated images to created or updated. */ images?: UpsertProductImageDTO[] + /** + * The id of the product in an external system + */ + external_id?: string /** * The product type id to associate with the product. */ @@ -1569,6 +1573,10 @@ export interface UpdateProductDTO { * The associated images to create or update. */ images?: UpsertProductImageDTO[] + /** + * The id of the product in an external system + */ + external_id?: string | null /** * The product type to associate with the product. */ diff --git a/packages/medusa/src/api/admin/products/validators.ts b/packages/medusa/src/api/admin/products/validators.ts index 2b63ebed97..b516fcd554 100644 --- a/packages/medusa/src/api/admin/products/validators.ts +++ b/packages/medusa/src/api/admin/products/validators.ts @@ -218,6 +218,7 @@ export const CreateProduct = z thumbnail: z.string().nullish(), handle: z.string().optional(), status: statusEnum.nullish().default(ProductStatus.DRAFT), + external_id: z.string().nullish(), type_id: z.string().nullish(), collection_id: z.string().nullish(), categories: z.array(IdAssociation).optional(), @@ -254,6 +255,7 @@ export const UpdateProduct = z thumbnail: z.string().nullish(), handle: z.string().nullish(), type_id: z.string().nullish(), + external_id: z.string().nullish(), collection_id: z.string().nullish(), categories: z.array(IdAssociation).optional(), tags: z.array(IdAssociation).optional(),