Smile-SA / elasticsuite

Smile ElasticSuite - Magento 2 merchandising and search engine built on ElasticSearch
https://elasticsuite.io
Open Software License 3.0
761 stars 341 forks source link

[ES2.6.7] `Invalid scope type 'containers_stores'` error in category and search-result pages after updating Magento CE 2.2.7 to 2.2.8 #1361

Closed lewisje closed 5 years ago

lewisje commented 5 years ago

When I go to a category page or use the site search, I get the error Invalid scope type 'containers_stores'; this does not happen on the home page or on a product page, or in the admin area.

Preconditions

Magento Version : CE 2.2.8

ElasticSuite Version : 2.6.7

Environment : Developer (I first noticed this in the Production site, leading me to temporarily disable the module.)

Third party modules :

Steps to reproduce

  1. Search for a product.
    • Alternatively, after making sure that the store has at least one category, navigate to a category page.

Expected result

  1. The category or search-result page loads normally.

Actual result

  1. full exception trace
Exception #0 (InvalidArgumentException): Invalid scope type 'containers_stores'
#1 Magento\Framework\App\Config\ScopeCodeResolver->resolve() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/RelevanceConfig/App/Config/ScopePool.php:92]
#2 Smile\ElasticsuiteCore\Search\Request\RelevanceConfig\App\Config\ScopePool->getScope() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/RelevanceConfig/App/Config.php:56]
#3 Smile\ElasticsuiteCore\Search\Request\RelevanceConfig\App\Config->getValue() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig/Factory.php:154]
#4 Smile\ElasticsuiteCore\Search\Request\ContainerConfiguration\RelevanceConfig\Factory->getConfigValue() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig/Factory.php:241]
#5 Smile\ElasticsuiteCore\Search\Request\ContainerConfiguration\RelevanceConfig\Factory->getMinimumShouldMatch() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig/Factory.php:131]
#6 Smile\ElasticsuiteCore\Search\Request\ContainerConfiguration\RelevanceConfig\Factory->loadConfiguration() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/ContainerConfiguration/RelevanceConfig/Factory.php:114]
#7 Smile\ElasticsuiteCore\Search\Request\ContainerConfiguration\RelevanceConfig\Factory->create() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/ContainerConfiguration.php:78]
#8 Smile\ElasticsuiteCore\Search\Request\ContainerConfiguration->__construct() called at [vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111]
#9 Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject() called at [vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:66]
#10 Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create() called at [vendor/magento/framework/ObjectManager/ObjectManager.php:56]
#11 Magento\Framework\ObjectManager\ObjectManager->create() called at [generated/code/Smile/ElasticsuiteCore/Search/Request/ContainerConfigurationFactory.php:43]
#12 Smile\ElasticsuiteCore\Search\Request\ContainerConfigurationFactory->create() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/Builder.php:214]
#13 Smile\ElasticsuiteCore\Search\Request\Builder->getRequestContainerConfiguration() called at [vendor/smile/elasticsuite/src/module-elasticsuite-core/Search/Request/Builder.php:137]
#14 Smile\ElasticsuiteCore\Search\Request\Builder->create() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/ResourceModel/Product/Fulltext/Collection.php:636]
#15 Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection->loadProductCounts() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/ResourceModel/Product/Fulltext/Collection.php:195]
#16 Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection->getSize() called at [generated/code/Smile/ElasticsuiteCatalog/Model/ResourceModel/Product/Fulltext/Collection/Interceptor.php:24]
#17 Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection\Interceptor->getSize() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/Layer/RelevantFilterList.php:69]
#18 Smile\ElasticsuiteCatalog\Model\Layer\RelevantFilterList->getCoverageRates() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/Layer/RelevantFilterList.php:37]
#19 Smile\ElasticsuiteCatalog\Model\Layer\RelevantFilterList->getRelevantFilters() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Block/Navigation.php:186]
#20 Smile\ElasticsuiteCatalog\Block\Navigation->addFacets() called at [vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Block/Navigation.php:174]
#21 Smile\ElasticsuiteCatalog\Block\Navigation->_prepareLayout() called at [vendor/magento/framework/View/Element/AbstractBlock.php:272]
#22 Magento\Framework\View\Element\AbstractBlock->setLayout() called at [vendor/magento/framework/View/Layout/Generator/Block.php:151]
#23 Magento\Framework\View\Layout\Generator\Block->process() called at [vendor/magento/framework/View/Layout/GeneratorPool.php:80]
#24 Magento\Framework\View\Layout\GeneratorPool->process() called at [vendor/magento/framework/View/Layout.php:343]
#25 Magento\Framework\View\Layout->generateElements() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:89]
#26 Magento\Framework\View\Layout\Interceptor->generateElements() called at [vendor/magento/framework/View/Layout/Builder.php:129]
#27 Magento\Framework\View\Layout\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Page/Builder.php:55]
#28 Magento\Framework\View\Page\Builder->generateLayoutBlocks() called at [vendor/magento/framework/View/Layout/Builder.php:65]
#29 Magento\Framework\View\Layout\Builder->build() called at [vendor/magento/framework/View/Page/Config.php:208]
#30 Magento\Framework\View\Page\Config->build() called at [vendor/magento/framework/View/Page/Config.php:544]
#31 Magento\Framework\View\Page\Config->getElementAttribute() called at [vendor/magento/framework/View/Page/Config.php:502]
#32 Magento\Framework\View\Page\Config->addBodyClass() called at [vendor/magento/module-catalog/Controller/Category/View.php:215]
#33 Magento\Catalog\Controller\Category\View->execute() called at [generated/code/Magento/Catalog/Controller/Category/View/Interceptor.php:24]
#34 Magento\Catalog\Controller\Category\View\Interceptor->execute() called at [vendor/magento/framework/App/Action/Action.php:107]
#35 Magento\Framework\App\Action\Action->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#36 Magento\Catalog\Controller\Category\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#37 Magento\Catalog\Controller\Category\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#38 Magento\Catalog\Controller\Category\View\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Controller/Category/View/Interceptor.php:39]
#39 Magento\Catalog\Controller\Category\View\Interceptor->dispatch() called at [vendor/magento/framework/App/FrontController.php:55]
#40 Magento\Framework\App\FrontController->dispatch() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#41 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#42 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php:94]
#43 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#44 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php:69]
#45 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#46 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [app/code/Infortis/Cgen/Plugin/Magento/Framework/App/FrontController.php:32]
#47 Infortis\Cgen\Plugin\Magento\Framework\App\FrontController->aroundDispatch() called at [vendor/magento/framework/Interception/Interceptor.php:135]
#48 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#49 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/App/FrontController/Interceptor.php:26]
#50 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [vendor/magento/framework/App/Http.php:136]
#51 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#52 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:257]
#53 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:37]

This error did not happen under Magento 2.2.7 with this version of ElasticSuite, and it does not happen if ElasticSuite is disabled; I tried installing ElasticSuite 2.7.x in case that might help (even though officially it is for Magento 2.3.x only), but it requires a higher version of PHP than my system has, so that would need to wait for later.

I also noticed that another Magento module ended up giving up on its own custom scope type when a similar error was reported.


In case it helps, this is the full changeset between 2.2.7 and 2.2.8, most notably including a new ToolbarMemorizer class; also, I am using this workaround to get the search bar to show up in the Ultimo theme.

lingwooc commented 5 years ago

I can second this. It also breaks the auto suggest search box.

mropanen commented 5 years ago

I'm also getting this on the Categories page in admin. Edit: this seems to be caused by \Magento\Framework\App\Config\ScopeCodeResolver::resolve, which used to set $resolverScopeCode = $scopeCode, but since this https://github.com/magento/magento2/commit/d79cfa9009034d8df1a37587ecbed2d62225d3d6?diff=split it doesn't anymore.

romainruaud commented 5 years ago

And ... another BC change on a minor version... great ...

Thank you for reporting it quickly, we gonna release a minor version to handle this change asap.

@mropanen I think you pointed the correct file. We'll have a look.

Thank you guys ! We keep you in touch

romainruaud commented 5 years ago

It appears that the code is only in 2.2 for now and has not been forward-ported to 2.3 (which is very bad ..).

Anyway, we should fix it on both Elasticsuite 2.6 and 2.7.

KEVWISNIEW commented 5 years ago

Hi,

here is a workaround with around plugin for temporary fix error `Invalid scope type 'containers_stores'' with Magento 2.2.8 C.E

<?php

namespace [Vendor]\[Module]\Plugin\Framework\App\Config;

use InvalidArgumentException;
use Magento\Framework\App\Config\ScopeCodeResolver as ConfigScopeCodeResolver;
use Magento\Framework\App\ScopeResolverPool;
use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;

/**
 * Class ScopeCodeResolver
 * @package [Vendor]\[Module]\Plugin\Framework\App\Config
 */
class ScopeCodeResolver
{

    /**
     * @var StoreManagerInterface
     */
    private $storeManager;

    /**
     * @var ScopeResolverPool
     */
    private $scopeResolverPool;

    /**
     * @var []
     */
    private $resolvedScopeCodes;

    /**
     * @var LoggerInterface
     */
    private $logger;

    /**
     * ScopeCodeResolver constructor.
     * @param StoreManagerInterface $storeManager
     * @param LoggerInterface $logger
     */
    public function __construct(
        ScopeResolverPool $scopeResolverPool,
        StoreManagerInterface $storeManager,
        LoggerInterface $logger
    ) {
        $this->scopeResolverPool = $scopeResolverPool;
        $this->storeManager = $storeManager;
        $this->logger = $logger;
    }

    public function aroundResolve(
        ConfigScopeCodeResolver $scopeCodeResolver,
        callable $proceed,
        $scopeType,
        $scopeCode
    ) {

        try {
            return $proceed($scopeType, $scopeCode);
        } catch (InvalidArgumentException $e) {
            $this->logger->error($e->getMessage());
        }

        if (!isset($this->resolvedScopeCodes[$scopeType][$scopeCode])) {
            $this->resolvedScopeCodes[$scopeType][$scopeCode] = $scopeCode;
        }

        return $this->resolvedScopeCodes[$scopeType][$scopeCode];
    }
}
rbayet commented 5 years ago

Hi @KEVWISNIEW,

I updated your comment to fix the code block rendering, but I didn't reviewed it. A minor release of ElasticSuite will be published today with our fix (#1362)

Regards,

rbayet commented 5 years ago

For future reference :

kevwis commented 5 years ago

the di.xml used for the plugin

`<?xml version="1.0"?>

`