Skip to content

Commit 7736450

Browse files
Added fieldType to search_products (#34)
Co-authored-by: Islam farg <islam.farg@commercetools.com>
1 parent 1971f11 commit 7736450

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

.changeset/wicked-pants-cut.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@commercetools/mcp-essentials": minor
3+
"@commercetools/agent-essentials": minor
4+
---
5+
6+
Added [fieldType](https://docs.commercetools.com/api/search-query-language#ctp:api:type:SearchFieldType) to search_products
7+
8+
Necessary when sorting by attributes to avoid errors like: `SDKError: Failed to search products Field [variants.attributes.weight]: Type is missing`

typescript/src/shared/product-search/parameters.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,35 @@ export const searchProductsParameters = z.object({
1818
.enum(['min', 'max'])
1919
.optional()
2020
.describe('The sorting mode for multi-valued fields'),
21+
fieldType: z
22+
.enum([
23+
'boolean',
24+
'text',
25+
'ltext',
26+
'enum',
27+
'lenum',
28+
'number',
29+
'money',
30+
'date',
31+
'datetime',
32+
'time',
33+
'reference',
34+
'set_boolean',
35+
'set_text',
36+
'set_ltext',
37+
'set_enum',
38+
'set_lenum',
39+
'set_number',
40+
'set_money',
41+
'set_date',
42+
'set_datetime',
43+
'set_time',
44+
'set_reference',
45+
])
46+
.optional()
47+
.describe(
48+
'The data type of the field. Must be provided when field is a non-standard field on a resource, like a Product Attribute'
49+
),
2150
})
2251
)
2352
.optional()

0 commit comments

Comments
 (0)