Skip to content

Exception #0 (Exception): Warning: Array to string conversion in /var/www/html/vendor/magento/module-swatches/Helper/Data.php on line 200 #3646

@lumnn

Description

@lumnn

Preconditions

Magento Version : Magento 2.4.7-p4

ElasticSuite Version : 2.11.13

Environment : both

Third party modules :

Steps to reproduce

  1. Add color swatch and enable filtering
  2. Have some products with custom images for swatches, and some without swatch variant image
  3. Filter by few colours

Expected result

  1. Filtering works

Actual result

Exception #0 (Exception): Warning: Array to string conversion in /var/www/html/vendor/magento/module-swatches/Helper/Data.php on line 200
<pre>#1 array_diff_assoc() called at [vendor/magento/module-swatches/Helper/Data.php:200]
#2 Magento\Swatches\Helper\Data->loadFirstVariation() called at [vendor/magento/module-swatches/Helper/Data.php:232]
#3 Magento\Swatches\Helper\Data->loadFirstVariationWithImage() called at [vendor/smile/elasticsuite/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php:101]
#4 Smile\ElasticsuiteSwatches\Model\Plugin\ProductImage->loadSimpleVariation() called at [vendor/smile/elasticsuite/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php:47]
#5 Smile\ElasticsuiteSwatches\Model\Plugin\ProductImage->beforeGetImage() called at [vendor/magento/framework/Interception/Interceptor.php:121]
#6 Magento\Catalog\Block\Product\ListProduct\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#7 Magento\Catalog\Block\Product\ListProduct\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php:329]

I've looked into where array comes to in first place and I've found that in src/vendor/smile/elasticsuite/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php:79 there is condition that adds option ids to array, which becomes a bit of a mixture of labels and ids.

Below screenshot of 2 debugging dump lines added after line 80

$filterArray[$code][] = $this->swatchHelperData->getOptionIds($attribute, $value);
dump($filterArray);
dump($this->swatchHelperData->getOptionIds($attribute, $value));

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions