This commit is contained in:
greeneclipse committed 2026-10-27 14:53:19 +01:00
1 parent c347d2418f
commit 1ad180a052
49 files changed
+6339 -89

No files matched your search

+20 -1
View File
@@ -235,13 +235,32 @@ func AttrsForPersist(attrs map[string]any, allowed map[string]struct{}) map[stri
// enhanceAllowedAttrKeys prefers category_attributes for the resolved category;
// falls back to AllowedAttrKeys (nil = sanitize-only for unit tests).
// Uncategorized products have no schema to enforce, so the supplier's own spec keys
// are allowed too: the model may refine them but cannot invent new keys.
func enhanceAllowedAttrKeys(in ProductInput, categoryUID string) map[string]struct{} {
if in.CategoryAttrKeys != nil {
return allowedAttrKeysFromSets(in.CategoryAttrKeys, categoryUID)
allowed := allowedAttrKeysFromSets(in.CategoryAttrKeys, categoryUID)
if strings.TrimSpace(categoryUID) == "" {
for k := range in.FeedAttrKeys {
allowed[k] = struct{}{}
}
}
return allowed
}
return in.AllowedAttrKeys
}
// attrKeySet returns the canonical keys of attrs (see FilterAttributesByAllowed).
func attrKeySet(attrs map[string]any) map[string]struct{} {
out := make(map[string]struct{}, len(attrs))
for k := range attrs {
if canon := canonicalizeAttrKey(k); canon != "" {
out[canon] = struct{}{}
}
}
return out
}
// FilterAttributesByAllowed keeps coreCharacteristicAttrKeys plus keys present in
// allowed (after canonicalizeAttrKey). When allowed is nil, returns attrs unchanged.
func FilterAttributesByAllowed(attrs map[string]any, allowed map[string]struct{}) map[string]any {