Closed sheepfy closed 2 years ago
I have somehow noticed that this can be fixed by replacing src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php::getFilterArray method with the original method, or commenting these lines:
// if (isset($filterArray[$code]) && !is_array($filterArray[$code])) { // $filterArray[$code] = [$filterArray[$code]]; // } // // if ($attribute->getId() && $this->canReplaceImageWithSwatch($attribute)) { // $filterArray[$code][] = $this->swatchHelperData->getOptionIds($attribute, $value); // }
I am not exactly sure what should happen in here. I have not dug that much.
Hello @sheepfy,
Please provide more details about your environment, such as version of PHP and which exactly version of Magento and the ElasticSuite you are using. Maybe you are using some custom theme in your store?
BR, Vadym
@vahonc Hi, it was a clean, latest Magento Commerce edition 2.4.4 (non enterprise, classic), with sample data. No extra products or attributes than what came from sample data and no changes added to the sample data products.
php version: 8.1 smile/elasticsuite 2.10.10 (latest).
@sheepfy, thanks for your feedback.
It looks like this issue could be linked to PHP 8 compatibility. I'll try to dig into it more.
BR, Vadym
@vahonc If you need, we can setup a sharescreen too, just let me know.
Hi @sheepfy,
Unfortunately, I was not able to reproduce your issue.
I installed fresh Magento 2.4.4 CE with default sample data and ElasticSuite 2.10.10, of course, I use PHP 8.1.
So, when I go to women/bottoms-women/pants-women
category and click on blue color in order to add ?color=Blue
to the URL
It showed me the correct filtered products without any errors. Please look at my screenshot below:
Have you tried to check how working color filtration before installing the ElasticSuite module, perhaps something is wrong with installed sample data? I checked it before and after installation ES and in both cases I see results which I expected.
Here're my steps for installation (maybe it will be useful for you):
$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.4 $ bin/magento sampledata:deploy $ bin/magento setup:install with params $ bin/magento setup:upgrade $ bin/magento setup:di:compile $ bin/magento setup:static-content:deploy -f $ bin/magento indexer:reindex $ bin/magento cache:clean $ composer require smile/elasticsuite ~2.10.0 $ bin/magento setup:upgrade $ bin/magento indexer:reindex $ bin/magento cache:clean
BR, Vadym
@vahonc OK, agree. I tried again and seems to work. We can close this, my bad.
In case it helps someone later, we had this issue (elasticsuite version 2.9.5, Magento version 2.3.7) and the bug was triggered by a configurable's subproduct having no product image. So adding the image solved the issue as a workaround.
btw the code causing this issue seems to be https://github.com/Smile-SA/elasticsuite/blob/2.10.x/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php and that is marked as deprecated since Magento 2.1.6 , so I assume it could be removed?
btw the code causing this issue seems to be https://github.com/Smile-SA/elasticsuite/blob/2.10.x/src/module-elasticsuite-swatches/Model/Plugin/ProductImage.php and that is marked as deprecated since Magento 2.1.6 , so I assume it could be removed?
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<!-- Smile_ElasticsuiteSwatches -->
<type name="Magento\Catalog\Block\Product\ListProduct">
<plugin name="add_product_object_to_image_data_array" disabled="true" />
</type>
<type name="Magento\CatalogSearch\Block\SearchResult\ListProduct">
<plugin name="add_product_object_to_image_data_array" disabled="true" />
</type>
</config>
Solved my issue on Magento 2.4.7 and with child products with no images.
Expected result: display correct filtered products
Actual result: Array to string conversion: 1 exception(s): Exception #0 (Exception): Warning: Array to string conversion in /magentohome/vendor/magento/module-swatches/Helper/Data.php on line 199
Exception #0 (Exception): Warning: Array to string conversion in /magentohome/vendor/magento/module-swatches/Helper/Data.php on line 199