This commit is contained in:
2026-08-16 16:57:36 +02:00
parent 96f8c1115c
commit 532d439c41
106 changed files with 10147 additions and 494 deletions
+9 -20
View File
@@ -1,7 +1,6 @@
package processing
import (
"fmt"
"regexp"
"strings"
)
@@ -67,10 +66,12 @@ func FillMissingFields(mapped map[string]any, attrs map[string]any) map[string]a
}
}
if stringFromAny(out["category"]) == "" {
if c := stringFromAny(attrs["category"]); c != "" {
out["category"] = c
}
if c := categoryUniqueIDFromAny(out["category"]); c != "" {
out["category"] = c
} else if c := categoryUniqueIDFromAny(attrs["category"]); c != "" {
out["category"] = c
} else if c := categoryUniqueIDFromAny(out["category_unique_id"]); c != "" {
out["category"] = c
}
if stringFromAny(out["stock_status"]) == "" {
@@ -142,19 +143,7 @@ func normalizeStockStatusLabel(s string) string {
}
func stringFromAny(v any) string {
if v == nil {
return ""
}
switch t := v.(type) {
case string:
return strings.TrimSpace(t)
case float64, float32, int, int64, bool:
s := strings.TrimSpace(fmt.Sprint(t))
if s == "<nil>" {
return ""
}
return s
default:
return ""
}
// Flatten arrays / #text wrappers; callers that need HTML-stripped descriptions
// should use PlainDescriptionFromAny (normalize + V1 enforce do that).
return coerceScalarText(v)
}