This commit is contained in:
mats committed 2026-07-26 13:01:07 +02:00
1 parent 540aa48c44
commit bd81f4ff54
8 files changed
+322 -4

No files matched your search

+4
View File
@@ -144,6 +144,10 @@ func Apply(s Schema, source map[string]any) (Projection, error) {
InventoryTracked: boolOf(source, s.InventoryTrackedF, truthy),
DropShip: boolOf(source, s.DropShipF, truthy),
Category: stringOf(source, s.CategoryField),
Category2: stringOf(source, s.Category2Field),
Category3: stringOf(source, s.Category3Field),
Category4: stringOf(source, s.Category4Field),
Category5: stringOf(source, s.Category5Field),
Brand: stringOf(source, s.BrandField),
Image: stringOf(source, s.ImageField),
UpdatedAt: upd,
+12 -1
View File
@@ -19,6 +19,10 @@
// inventory_tracked ← bool coercion of source[InventoryTrackedField]
// drop_ship ← bool coercion of source[DropShipField]
// category ← source[CategoryField] (omitempty)
// category2 ← source[Category2Field] (omitempty)
// category3 ← source[Category3Field] (omitempty)
// category4 ← source[Category4Field] (omitempty)
// category5 ← source[Category5Field] (omitempty)
// brand ← source[BrandField] (omitempty)
// image ← source[ImageField] (omitempty)
// updated_at ← Unix-ms from source[UpdatedAtField] OR stamped at
@@ -75,7 +79,10 @@ import (
// asks for these so the cart can pre-mark drop-ship
// items before checkout and inventory can opt-out of
// tracking for non-stock items.
// Category / Brand / Image — display projection only.
// Category* / Brand / Image — display projection only.
// Category2–Category5 extend category with deeper taxonomy levels for
// promotions engine multi-level matching and tracking personas.
// Each level is optional; an empty string means "not published".
// UpdatedAt — version stamp for snapshot + revalidate.
//
// WIRE-COMPAT: adding a field is forward+backward-safe. Old snapshot
@@ -97,6 +104,10 @@ type Projection struct {
InventoryTracked bool `json:"inventory_tracked"`
DropShip bool `json:"drop_ship"`
Category string `json:"category,omitempty"`
Category2 string `json:"category2,omitempty"`
Category3 string `json:"category3,omitempty"`
Category4 string `json:"category4,omitempty"`
Category5 string `json:"category5,omitempty"`
Brand string `json:"brand,omitempty"`
Image string `json:"image,omitempty"`
UpdatedAt int64 `json:"updated_at"`
+12
View File
@@ -59,6 +59,10 @@ type Schema struct {
InventoryTrackedF string `json:"inventory_tracked_field,omitempty"`
DropShipF string `json:"drop_ship_field,omitempty"`
CategoryField string `json:"category_field,omitempty"`
Category2Field string `json:"category2_field,omitempty"`
Category3Field string `json:"category3_field,omitempty"`
Category4Field string `json:"category4_field,omitempty"`
Category5Field string `json:"category5_field,omitempty"`
BrandField string `json:"brand_field,omitempty"`
ImageField string `json:"image_field,omitempty"`
// AttributesFields names the keys in the source map[string]any that
@@ -125,6 +129,10 @@ func DefaultSchema() Schema {
InventoryTrackedF: "inventory_tracked",
DropShipF: "drop_ship",
CategoryField: "category",
Category2Field: "category2",
Category3Field: "category3",
Category4Field: "category4",
Category5Field: "category5",
BrandField: "brand",
ImageField: "image",
// Standard product service carries the integer catalog id under "id".
@@ -165,6 +173,10 @@ func BygglagretSchema() Schema {
InventoryTrackedF: "StockTracked",
DropShipF: "DropshipFlag",
CategoryField: "CategoryPath",
Category2Field: "Category2",
Category3Field: "Category3",
Category4Field: "Category4",
Category5Field: "Category5",
BrandField: "Brand",
ImageField: "PrimaryImage",
ItemIdField: "item_id",