Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(medusa, types): allow to pass external_id on product create/update #9694

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/core/types/src/http/product/admin/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }[]
Expand Down Expand Up @@ -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 }[]
Expand Down
8 changes: 8 additions & 0 deletions packages/core/types/src/product/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions packages/medusa/src/api/admin/products/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
Loading