From a9b993182b31296ef48312f166ac775255c3a8d8 Mon Sep 17 00:00:00 2001 From: Konstantinos Arvanitakis Date: Thu, 24 Sep 2026 22:00:28 +0300 Subject: [PATCH] Fix: Product Localizer now checks if a value is filled, or, not to show the fallback --- src/Catalog/Support/ProductDocumentLocalizer.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Catalog/Support/ProductDocumentLocalizer.php b/src/Catalog/Support/ProductDocumentLocalizer.php index fb43ebd..5d154a3 100644 --- a/src/Catalog/Support/ProductDocumentLocalizer.php +++ b/src/Catalog/Support/ProductDocumentLocalizer.php @@ -51,7 +51,15 @@ class ProductDocumentLocalizer $availableLocales = $this->languages->availableLocales(); foreach ($this->translatedAttributeHandles() as $handle) { - $product[$handle] = $product[$handle.'_'.$locale] ?? $product[$handle.'_'.$fallbackLocale] ?? null; + // filled(), not ?? - a translated attribute saved blank for + // the current locale still has that {handle}_{locale} key in + // the document, just set to '' rather than absent. ?? only + // falls back on a missing/null key, so it kept the empty + // string instead of falling through to a locale that actually + // has content. + $product[$handle] = filled($product[$handle.'_'.$locale] ?? null) + ? $product[$handle.'_'.$locale] + : ($product[$handle.'_'.$fallbackLocale] ?? null); foreach ($availableLocales as $availableLocale) { unset($product[$handle.'_'.$availableLocale]);