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

Virtual sub - sub categorie has too many products #3234

Closed
gerrits-ecommerce opened this issue Mar 28, 2024 · 4 comments
Closed

Virtual sub - sub categorie has too many products #3234

gerrits-ecommerce opened this issue Mar 28, 2024 · 4 comments

Comments

@gerrits-ecommerce
Copy link

Since the update from ElasticSuite 2.11.5.1 > 2.11.5.3 we have encoutered a problem where the virutal sub sub categories have to many products, also we cannot edit them in the backoffice of Magento 2.

In the back-end we get the following error when trying to edit the category.

image

[2024-03-21T13:51:23.261841+00:00] main.CRITICAL: TypeError: Smile\ElasticsuiteVirtualCategory\Model\Preview::getQueryFilter(): Return value must be of type Smile\ElasticsuiteCore\Search\Request\QueryInterface, null returned in /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php:141 Stack trace: #0 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php(87): Smile\ElasticsuiteVirtualCategory\Model\Preview->getQueryFilter() #1 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/ProductSorter/AbstractPreview.php(158): Smile\ElasticsuiteVirtualCategory\Model\Preview->prepareProductCollection(Object(Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\Collection\Interceptor)) #2 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/ProductSorter/AbstractPreview.php(199): Smile\ElasticsuiteCatalog\Model\ProductSorter\AbstractPreview->getProductCollection() #3 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Model/ProductSorter/AbstractPreview.php(101): Smile\ElasticsuiteCatalog\Model\ProductSorter\AbstractPreview->getUnsortedProductData() #4 /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Controller/Adminhtml/Category/Virtual/Preview.php(70): Smile\ElasticsuiteCatalog\Model\ProductSorter\AbstractPreview->getData() #5 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview->execute() #6 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->___callParent('...', Array) #7 /data/web/magento2_staging/vendor/meta/module-business-extension/Plugin/LoggingPluginBase.php(137): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->Magento\Framework\Interception\{closure}() #8 /data/web/magento2_staging/vendor/meta/module-business-extension/Plugin/LoggingPluginBase.php(85): Meta\BusinessExtension\Plugin\LoggingPluginBase->wrapCallableWithLogging(true, true, '...', Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor), Object(Closure)) #9 /data/web/magento2_staging/vendor/meta/module-business-extension/Plugin/LoggingActionPlugin.php(45): Meta\BusinessExtension\Plugin\LoggingPluginBase->wrapCallableWithErrorAndImpressionLogging('...', Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor), Object(Closure)) #10 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(135): Meta\BusinessExtension\Plugin\LoggingActionPlugin->aroundExecute(Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor), Object(Closure)) #11 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->Magento\Framework\Interception\{closure}() #12 /data/web/magento2_staging/generated/code/Smile/ElasticsuiteVirtualCategory/Controller/Adminhtml/Category/Virtual/Preview/Interceptor.php(23): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->___callPlugins('...', Array, Array) #13 /data/web/magento2_staging/vendor/magento/framework/App/Action/Action.php(111): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->execute() #14 /data/web/magento2_staging/vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http)) #15 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http)) #16 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->___callParent('...', Array) #17 /data/web/magento2_staging/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(145): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #18 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http)) #19 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #20 /data/web/magento2_staging/generated/code/Smile/ElasticsuiteVirtualCategory/Controller/Adminhtml/Category/Virtual/Preview/Interceptor.php(32): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->___callPlugins('...', Array, Array) #21 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(245): Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #22 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse(Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor), Object(Magento\Framework\App\Request\Http)) #23 /data/web/magento2_staging/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Smile\ElasticsuiteVirtualCategory\Controller\Adminhtml\Category\Virtual\Preview\Interceptor)) #24 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http)) #25 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('...', Array) #26 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http)) #27 /data/web/magento2_staging/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins('...', Array, Array) #28 /data/web/magento2_staging/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http)) #29 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch() #30 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent('...', Array) #31 /data/web/magento2_staging/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}() #32 /data/web/magento2_staging/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins('...', Array, Array) #33 /data/web/magento2_staging/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch() #34 /data/web/magento2_staging/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #35 {main} {"exception":"[object] (TypeError(code: 0): Smile\\ElasticsuiteVirtualCategory\\Model\\Preview::getQueryFilter(): Return value must be of type Smile\\ElasticsuiteCore\\Search\\Request\\QueryInterface, null returned at /data/web/magento2_staging/vendor/smile/elasticsuite/src/module-elasticsuite-virtual-category/Model/Preview.php:141)"} []

Preconditions

Magento Version : 2.4.6-p4

ElasticSuite Version : 2.11.5.3

Environment : production

Third party modules : Hyva theme

Steps to reproduce

  1. Go to sub sub category that is a virtual category

Expected result

Correct: (live, with ElasticSuite 2.11.5.1):

image

Actual result

Wrong (staging, with ElasticSuite 2.11.5.3):

image

Tomasz-Silpion added a commit to lcbrq/magento2-elasticsuite that referenced this issue Mar 28, 2024
@Tomasz-Silpion
Copy link

Tomasz-Silpion commented Mar 28, 2024

I think the issue is caused by recent 02db338 cache implementation as unserialize method can return empty values.

We've got same issue on production environment today. Simplest, as far working solution in PR below.

https://github.com/Smile-SA/elasticsuite/pull/3236/files

Composer patch:

        "magento-force": "override",
        "patches": {
	    "smile/elasticsuite": {
                "Fixes #3234 TypeError on wrong query unserialization": "https://github.com/Smile-SA/elasticsuite/commit/32040b1e4ed0a0fc15dad736ab21d0c448509c94.patch"
            }
        }
    }

@gerrits-ecommerce
Copy link
Author

@Tomasz-Silpion Thank you for providing the patch, this fixes the problem.

@romainruaud
Copy link
Collaborator

I reopen, will close this as soon as the attached PR is merged.

Thanks for contributing anyway !

@PierreGauthier
Copy link
Contributor

Hello @gerrits-ecommerce , @Tomasz-Silpion ,
I create a new PR to fix this issue,
I think instead forcing recalculate null query, we should prevent caching them. Because if we force recalculate null query, we might calculate the multiple times legitimate null query.
Can you confirm that this approach solves your issue?
Thank you

rbayet added a commit that referenced this issue Apr 10, 2024
@rbayet rbayet closed this as completed in 9811ee7 Apr 10, 2024
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