Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smile elasticsuite has conflict with Amasty Multiple Wishlist for Magento 2 #3392

Closed
gerrits-ecommerce opened this issue Sep 19, 2024 · 3 comments
Assignees

Comments

@gerrits-ecommerce
Copy link

While using Amasty Multiple Wishlist i`m encountering this error. I was wondering if this is a known issue, and if somebody has fixed this before. Maybe Smile is interested to take a look at this since both modules are used a lot.

[2024-09-13T17:42:05.725840+00:00] main.CRITICAL: TypeError: Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Mapper::buildSearchRequest(): Argument #1 ($request) must be of type Smile\ElasticsuiteCore\Search\RequestInterface, Magento\Framework\Search\Request given, called in /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php on line 104 and defined in /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Mapper.php:79
Stack trace:
#0 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php(104): Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Request\Mapper->buildSearchRequest()
#1 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php(82): Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Adapter->doSearch()
#2 /data/web/magento2_staging/vendor/magento/module-search/Model/SearchEngine.php(42): Smile\ElasticsuiteCore\Search\Adapter\Elasticsuite\Adapter->query()
#3 /data/web/magento2_staging/vendor/magento/framework/Search/Search.php(85): Magento\Search\Model\SearchEngine->search()
#4 /data/web/magento2_staging/vendor/amasty/module-multiple-wishlist/Model/Product/Search.php(204): Magento\Framework\Search\Search->search()
#5 /data/web/magento2_staging/vendor/amasty/module-multiple-wishlist/Model/Product/Search.php(178): Amasty\MWishlist\Model\Product\Search->searchProductIds()
#6 /data/web/magento2_staging/vendor/amasty/module-multiple-wishlist/Model/Product/Search.php(136): Amasty\MWishlist\Model\Product\Search->getProductCollection()
#7 /data/web/magento2_staging/vendor/amasty/module-multiple-wishlist/Model/Product/Search.php(125): Amasty\MWishlist\Model\Product\Search->generateSearchResult()
#8 /data/web/magento2_staging/vendor/amasty/module-multiple-wishlist/Controller/Product/Search.php(55): Amasty\MWishlist\Model\Product\Search->search()
#9 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Amasty\MWishlist\Controller\Product\Search->execute()
#10 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Amasty\MWishlist\Controller\Product\Search\Interceptor->___callParent()
#11 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Amasty\MWishlist\Controller\Product\Search\Interceptor->Magento\Framework\Interception\{closure}()
#12 /data/web/magento2_staging/generated/code/Amasty/MWishlist/Controller/Product/Search/Interceptor.php(23): Amasty\MWishlist\Controller\Product\Search\Interceptor->___callPlugins()
#13 /data/web/magento2_staging/vendor/magento/framework/App/Action/Action.php(111): Amasty\MWishlist\Controller\Product\Search\Interceptor->execute()
#14 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch()
#15 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Amasty\MWishlist\Controller\Product\Search\Interceptor->___callParent()
#16 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Amasty\MWishlist\Controller\Product\Search\Interceptor->Magento\Framework\Interception\{closure}()
#17 /data/web/magento2_staging/generated/code/Amasty/MWishlist/Controller/Product/Search/Interceptor.php(32): Amasty\MWishlist\Controller\Product\Search\Interceptor->___callPlugins()
#18 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(245): Amasty\MWishlist\Controller\Product\Search\Interceptor->dispatch()
#19 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#20 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(146): Magento\Framework\App\FrontController->processRequest()
#21 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#22 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#23 /data/web/magento2_staging/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#24 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch()
#25 /data/web/magento2_staging/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(75): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#26 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#27 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#28 /data/web/magento2_staging/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#29 /data/web/magento2_staging/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#30 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#31 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#32 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#33 /data/web/magento2_staging/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#34 /data/web/magento2_staging/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#35 /data/web/magento2_staging/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#36 {main} {"exception":"[object] (TypeError(code: 0): Smile\\ElasticsuiteCore\\Search\\Adapter\\Elasticsuite\\Request\\Mapper::buildSearchRequest(): Argument #1 ($request) must be of type Smile\\ElasticsuiteCore\\Search\\RequestInterface, Magento\\Framework\\Search\\Request given, called in /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Adapter.php on line 104 at /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Adapter/Elasticsuite/Request/Mapper.php:79)"} []

Preconditions

Magento Version : 2.4.6-p5

ElasticSuite Version : 2.11.8.3

Third party modules : Amasty Multiple Wishlist

Steps to reproduce

Expected result

Actual result

  1. [Screenshot, logs]
@vahonc
Copy link
Collaborator

vahonc commented Sep 23, 2024

Hello @gerrits-ecommerce,

Thanks for your feedback.

Compatibility with third-party modules is out of the scope of our Open Source support policy provided here, unfortunately, there is not much we can do for your issue. It's unlikely that our module and another one working on the same area will function correctly. Also, you should understand that ElasticSuite is a free module, but Amasty Multiple Wishlist is not. So, if you paid for this module, you can ask them about this fix.

BR,
Vadym

@gerrits-ecommerce
Copy link
Author

Sadly Amasty also wouldn't help us writing this compatibility. So we dit it ourselves. For now the following plugin seems to do the trick:

etc/frontend/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Framework\Search\Request\Builder">
        <plugin name="build_elastic_search_request"
                type="GerritsEcommerce\AmastyWishlistElasticSuiteCompatability\Plugin\BuildElasticSearchRequest"/>
    </type>
</config>
<?php

namespace GerritsEcommerce\AmastyWishlistElasticSuiteCompatability\Plugin;

use Magento\Framework\Search\Request\Builder;
use Magento\Framework\Search\RequestInterface;
use Magento\Store\Model\StoreManagerInterface;

class BuildElasticSearchRequest
{
    public function __construct(
        private \Smile\ElasticsuiteCore\Search\Request\Builder $requestBuilder,
        private StoremanagerInterface $storeManager,
    )
    {
    }

    /**
     * @param Builder $subject
     * @param RequestInterface $result
     * @return RequestInterface
     */
    public function afterCreate(Builder $subject, RequestInterface $result): RequestInterface
    {
        return $this->requestBuilder->create(
            $this->storeManager->getStore()->getId(),
            'catalog_product_autocomplete',
            $result->getFrom(),
            $result->getSize(),
            $_POST['q']
        );
    }
}

@romainruaud
Copy link
Collaborator

good catch, you could probably replace the hardcoded 'catalog_product_autocomplete' by $result->getName().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@romainruaud @gerrits-ecommerce @vahonc and others