From a272e3865e77c008c369acd7fe8a2e66b855a07f Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Tue, 10 Mar 2026 10:03:39 +0100 Subject: [PATCH] [Swatch] Fix error when value is not an array fixes #3800 --- src/module-elasticsuite-swatches/Helper/Swatches.php | 7 +++++-- .../Model/Plugin/ProductImage.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/module-elasticsuite-swatches/Helper/Swatches.php b/src/module-elasticsuite-swatches/Helper/Swatches.php index c473d35e8..c2bb78db6 100644 --- a/src/module-elasticsuite-swatches/Helper/Swatches.php +++ b/src/module-elasticsuite-swatches/Helper/Swatches.php @@ -90,8 +90,11 @@ public function loadFirstVariationWithImage(ProductInterface $configurableProduc foreach ($usedProducts as $simpleProduct) { foreach ($requiredAttributes as $attributeCode => $requiredValues) { - if (!in_array($simpleProduct->getData($attributeCode), $requiredValues)) { - break 2; + if (!in_array( + $simpleProduct->getData($attributeCode), + is_array($requiredValues) ? $requiredValues : [$requiredValues] + )) { + continue 2; } } diff --git a/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php b/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php index c4a418eb2..23186ea3e 100644 --- a/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php +++ b/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php @@ -90,7 +90,7 @@ private function getFilterArray(array $request, \Magento\Catalog\Model\Product $ private function loadSimpleVariation(Product $parentProduct, array $filterArray) { $childProduct = $this->swatchHelperData->loadVariationByFallback($parentProduct, $filterArray); - if ($childProduct && !$childProduct->getImage()) { + if ($childProduct && (!$childProduct->getImage() || $childProduct->getImage() == 'no_selection')) { $childProduct = $this->swatchHelperData->loadFirstVariationWithImage($parentProduct, $filterArray); } if (!$childProduct) {