fix: propager le type réel du métachamp Shopify pour éviter les erreurs 422
This commit is contained in:
@@ -35,7 +35,7 @@ export function matchMetafields(columnHeaders: string[], definitions: MetafieldD
|
|||||||
const key = normalizeMetafieldKey(header)
|
const key = normalizeMetafieldKey(header)
|
||||||
const def = definitions.find(d => d.key === key)
|
const def = definitions.find(d => d.key === key)
|
||||||
if (def) {
|
if (def) {
|
||||||
matched[header] = { columnHeader: header, action: 'map', namespace: def.namespace, key: def.key, existingDefinitionId: def.id }
|
matched[header] = { columnHeader: header, action: 'map', namespace: def.namespace, key: def.key, type: def.type, existingDefinitionId: def.id }
|
||||||
} else {
|
} else {
|
||||||
unmatched.push(header)
|
unmatched.push(header)
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,7 @@ export async function setProductMetafield(
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers,
|
headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
metafield: { namespace: resolution.namespace, key: resolution.key, value, type: 'single_line_text_field' },
|
metafield: { namespace: resolution.namespace, key: resolution.key, value, type: resolution.type ?? 'single_line_text_field' },
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export interface MetafieldResolution {
|
|||||||
action: 'create' | 'map' | 'skip'
|
action: 'create' | 'map' | 'skip'
|
||||||
namespace: string // "custom" par défaut
|
namespace: string // "custom" par défaut
|
||||||
key: string // clé normalisée
|
key: string // clé normalisée
|
||||||
|
type?: string // type Shopify réel, ex: 'multi_line_text_field', 'number_decimal'
|
||||||
existingDefinitionId?: string // si action === 'map'
|
existingDefinitionId?: string // si action === 'map'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user