This commit is contained in:
2026-08-16 12:23:14 +02:00
parent 52fb129957
commit 1d3a9d5abd
4 changed files with 192 additions and 18 deletions
+14 -7
View File
@@ -75,8 +75,9 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
}
}
attrs = parsed
out.Attributes = attrs
out.ProcessedAttributes = attrs
out.Attributes = SanitizeProductAttributes(attrs)
out.ProcessedAttributes = out.Attributes
attrs = out.Attributes
out.FieldSources["attributes"] = "specifications"
appendStepLog(out.GPTResponse, StepParseSpecs, map[string]any{
"count": len(attrs),
@@ -100,12 +101,15 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
in.Description,
)
out.Category = stringFromAny(normalized["category"])
// Promote filled scalar fields into attributes when useful
promote := []string{"brand", "width", "height", "depth", "weight", "gtin", "stock_status"}
// Promote characteristic fields only — never core product identity/content
// (those belong on the V1 item root: title, description, ean, images, …).
promote := []string{"brand", "width", "height", "depth", "weight", "product_model", "warranty"}
for _, f := range in.StandardFields {
if f.Key != "" {
promote = append(promote, f.Key)
k := strings.TrimSpace(f.Key)
if k == "" || isReservedProductKey(k) || isInvalidAttributeKey(k) {
continue
}
promote = append(promote, k)
}
seen := map[string]bool{}
for _, k := range promote {
@@ -120,6 +124,7 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
out.FieldSources[k] = "fill_fields"
}
}
attrs = SanitizeProductAttributes(attrs)
out.Attributes = attrs
out.ProcessedAttributes = attrs
appendStepLog(out.GPTResponse, StepFillFields, map[string]any{
@@ -411,7 +416,9 @@ func (e *Engine) RunSteps(ctx context.Context, companyID string, in ProductInput
if out.Attributes == nil {
out.Attributes = map[string]any{}
}
if out.ProcessedAttributes == nil {
out.Attributes = SanitizeProductAttributes(out.Attributes)
out.ProcessedAttributes = SanitizeProductAttributes(out.ProcessedAttributes)
if len(out.ProcessedAttributes) == 0 {
out.ProcessedAttributes = out.Attributes
}
if out.AIProviderMode == "" {