Skip to content

Commit

Permalink
feat(medusa): add sku to variant query params (#11151)
Browse files Browse the repository at this point in the history
what:

- adds sku to variant query params
  • Loading branch information
riqwan authored Jan 28, 2025
1 parent dab28e8 commit 8af4fb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/core/types/src/product/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ export interface FilterableProductProps
* The handles to filter products by.
*/
handle?: string | string[]
/**
* The skus to filter products by.
*/
sku?: string | string[]
/**
* The IDs to filter products by.
*/
Expand Down Expand Up @@ -1239,7 +1243,7 @@ export interface UpdateProductOptionValueDTO {

/**
* @interface
*
*
* Inventory kit for creating a product variant.
*/
export interface CreateProductVariantInventoryKit {
Expand Down
11 changes: 8 additions & 3 deletions packages/medusa/src/api/store/products/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export const StoreGetProductParams = createSelectParams().merge(
export const StoreGetProductVariantsParamsFields = z.object({
q: z.string().optional(),
id: z.union([z.string(), z.array(z.string())]).optional(),
options: z.object({ value: z.string().optional(), option_id: z.string().optional() }).optional(),
sku: z.union([z.string(), z.array(z.string())]).optional(),
options: z
.object({ value: z.string().optional(), option_id: z.string().optional() })
.optional(),
created_at: createOperatorMap().optional(),
updated_at: createOperatorMap().optional(),
deleted_at: createOperatorMap().optional(),
Expand Down Expand Up @@ -64,10 +67,12 @@ export const StoreGetProductsParams = createFindParams({
z
.object({
variants: z

.object({
options: z
.object({ value: z.string().optional(), option_id: z.string().optional() })
.object({
value: z.string().optional(),
option_id: z.string().optional(),
})
.optional(),
})
.merge(applyAndAndOrOperators(StoreGetProductVariantsParamsFields))
Expand Down

0 comments on commit 8af4fb0

Please sign in to comment.