Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -101,6 +101,14 @@ func productSeriesFallbackAutoCreateEnabled() bool {
|
|||||||
return raw == "1" || raw == "true" || raw == "on" || raw == "yes"
|
return raw == "1" || raw == "true" || raw == "on" || raw == "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func productSeriesFallbackLogEnabled() bool {
|
||||||
|
raw := strings.TrimSpace(strings.ToLower(os.Getenv("PRODUCT_SERIES_FALLBACK_LOG")))
|
||||||
|
if raw == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return raw == "1" || raw == "true" || raw == "on" || raw == "yes"
|
||||||
|
}
|
||||||
|
|
||||||
func productSeriesFallbackCode() string {
|
func productSeriesFallbackCode() string {
|
||||||
code := strings.TrimSpace(os.Getenv("PRODUCT_SERIES_FALLBACK_SERIES_CODE"))
|
code := strings.TrimSpace(os.Getenv("PRODUCT_SERIES_FALLBACK_SERIES_CODE"))
|
||||||
if code == "" {
|
if code == "" {
|
||||||
@@ -485,11 +493,14 @@ func productSeriesApplyVariant(ctx context.Context, pg *sql.DB, v productSeriesA
|
|||||||
return 0, 1, err
|
return 0, 1, err
|
||||||
}
|
}
|
||||||
if !ready {
|
if !ready {
|
||||||
|
if productSeriesFallbackLogEnabled() {
|
||||||
|
log.Printf("[ProductSeriesFallback] skip_not_ready product=%s color=%s dim3=%s", strings.TrimSpace(v.ProductCode), strings.TrimSpace(v.ColorCode), strings.TrimSpace(v.Dim3Code))
|
||||||
|
}
|
||||||
return 0, 1, nil
|
return 0, 1, nil
|
||||||
}
|
}
|
||||||
selected := productSeriesSelectRules(v, rules)
|
selected := productSeriesSelectRules(v, rules)
|
||||||
if len(selected) == 0 {
|
if len(selected) == 0 {
|
||||||
fallbackID, _, err := productSeriesResolveFallbackSeries(ctx, pg)
|
fallbackID, fallbackCode, err := productSeriesResolveFallbackSeries(ctx, pg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 1, err
|
return 0, 1, err
|
||||||
}
|
}
|
||||||
@@ -505,15 +516,24 @@ WHERE mmitem_id=$1
|
|||||||
LIMIT 1
|
LIMIT 1
|
||||||
`, mmitemID, dim1ID, nullableInt64ForAuto(dim3ID)).Scan(&exists)
|
`, mmitemID, dim1ID, nullableInt64ForAuto(dim3ID)).Scan(&exists)
|
||||||
if checkErr == nil {
|
if checkErr == nil {
|
||||||
|
if productSeriesFallbackLogEnabled() {
|
||||||
|
log.Printf("[ProductSeriesFallback] already_exists product=%s color=%s dim3=%s fallback=%s(%d)", strings.TrimSpace(v.ProductCode), strings.TrimSpace(v.ColorCode), strings.TrimSpace(v.Dim3Code), strings.TrimSpace(fallbackCode), fallbackID)
|
||||||
|
}
|
||||||
// keep existing manual/previous assignment; nothing to do
|
// keep existing manual/previous assignment; nothing to do
|
||||||
return 0, 0, nil
|
return 0, 0, nil
|
||||||
}
|
}
|
||||||
if checkErr != nil && checkErr != sql.ErrNoRows {
|
if checkErr != nil && checkErr != sql.ErrNoRows {
|
||||||
return 0, 1, checkErr
|
return 0, 1, checkErr
|
||||||
}
|
}
|
||||||
|
if productSeriesFallbackLogEnabled() {
|
||||||
|
log.Printf("[ProductSeriesFallback] apply product=%s color=%s dim3=%s fallback=%s(%d)", strings.TrimSpace(v.ProductCode), strings.TrimSpace(v.ColorCode), strings.TrimSpace(v.Dim3Code), strings.TrimSpace(fallbackCode), fallbackID)
|
||||||
|
}
|
||||||
// Use the fallback series as the single selected rule.
|
// Use the fallback series as the single selected rule.
|
||||||
selected = []productSeriesAutoRule{{SeriesID: fallbackID}}
|
selected = []productSeriesAutoRule{{SeriesID: fallbackID}}
|
||||||
} else {
|
} else {
|
||||||
|
if productSeriesFallbackLogEnabled() {
|
||||||
|
log.Printf("[ProductSeriesFallback] missing_fallback product=%s color=%s dim3=%s fallback_code=%s", strings.TrimSpace(v.ProductCode), strings.TrimSpace(v.ColorCode), strings.TrimSpace(v.Dim3Code), strings.TrimSpace(fallbackCode))
|
||||||
|
}
|
||||||
return 0, 1, nil
|
return 0, 1, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user