swissup / module-search-mysql-legacy

102 stars 32 forks source link

Column not found: '_id_filter._id' (Magento 2.4.5-p1) #11

Closed jfmontanaro closed 1 year ago

jfmontanaro commented 1 year ago

Hi,

I'm getting the following error after installing this extension in Magento 2.4.5-p1 when I try to hit a category or search results page:

Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S22]: Column not found: 1054 Unknown column '_id_filter._id' in 'where clause', query was: INSERT INTO `search_tmp_636d2888d9fe88_50721621` (`entity_id`, `score`) SELECT `main_select`.`entity_id`, SUM(score) AS `relevance` FROM (SELECT DISTINCT  `search_index`.`entity_id`, (((0) + (0) + (0)) * 1) AS `score` FROM `catalog_product_index_eav` AS `search_index`
 INNER JOIN `cataloginventory_stock_status` AS `stock_index` ON stock_index.product_id = search_index.entity_id AND `stock_index`.`website_id` = 0 AND `stock_index`.`stock_id` = 1
 INNER JOIN `catalog_category_product_index_store1` AS `category_ids_index` ON search_index.entity_id = category_ids_index.product_id AND category_ids_index.store_id = '1' WHERE (search_index.store_id = '1') AND (`search_index`.`attribute_id` = 99 AND `search_index`.`value` in ('2', '4') AND `search_index`.`store_id` = '1') AND (category_ids_index.category_id in ('10')) AND (`_id_filter`.`_id` NOT IN ('182', '183', '184'))) AS `main_select` GROUP BY `entity_id` ORDER BY `relevance` DESC, `entity_id` DESC
 LIMIT 10000

Full stack trace:


#2 Zend_Db_Statement->execute() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php:480]
#3 Zend_Db_Adapter_Abstract->query() called at [vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:238]
#4 Zend_Db_Adapter_Pdo_Abstract->query() called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:564]
#5 Magento\Framework\DB\Adapter\Pdo\Mysql->_query() called at [vendor/magento/framework/DB/Adapter/Pdo/Mysql.php:634]
#6 Magento\Framework\DB\Adapter\Pdo\Mysql->query() called at [generated/code/Magento/Framework/DB/Adapter/Pdo/Mysql/Interceptor.php:95]
#7 Magento\Framework\DB\Adapter\Pdo\Mysql\Interceptor->query() called at [app/code/Swissup/SearchMysqlLegacy/SearchAdapter/Mysql/TemporaryStorage.php:117]
#8 Swissup\SearchMysqlLegacy\SearchAdapter\Mysql\TemporaryStorage->storeDocumentsFromSelect() called at [app/code/Swissup/SearchMysqlLegacy/SearchAdapter/Mysql/Adapter.php:103]
#9 Swissup\SearchMysqlLegacy\SearchAdapter\Mysql\Adapter->query() called at [vendor/magento/module-search/Model/SearchEngine.php:42]
#10 Magento\Search\Model\SearchEngine->search() called at [vendor/magento/framework/Search/Search.php:85]
#11 Magento\Framework\Search\Search->search() called at [vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php:464]
#12 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection->_renderFiltersBefore() called at [vendor/magento/framework/Data/Collection/AbstractDb.php:343]
#13 Magento\Framework\Data\Collection\AbstractDb->_renderFilters() called at [vendor/magento/module-catalog-search/Model/ResourceModel/Fulltext/Collection.php:582]
#14 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection->_renderFilters() called at [vendor/magento/module-eav/Model/Entity/Collection/AbstractCollection.php:929]
#15 Magento\Eav\Model\Entity\Collection\AbstractCollection->load() called at [vendor/magento/module-catalog/Model/ResourceModel/Product/Collection.php:801]
#16 Magento\Catalog\Model\ResourceModel\Product\Collection->load() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#17 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#18 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#19 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->___callPlugins() called at [generated/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection/Interceptor.php:257]
#20 Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection\Interceptor->load() called at [vendor/magento/module-catalog/Block/Product/ListProduct.php:199]
#21 Magento\Catalog\Block\Product\ListProduct->_beforeToHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1094]
#22 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#23 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#24 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#25 Magento\Catalog\Block\Product\ListProduct\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#26 Magento\Catalog\Block\Product\ListProduct\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#27 Magento\Catalog\Block\Product\ListProduct\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Block/Product/ListProduct/Interceptor.php:617]
#28 Magento\Catalog\Block\Product\ListProduct\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#29 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]
#30 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#31 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#32 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#33 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Element/AbstractBlock.php:507]
#34 Magento\Framework\View\Element\AbstractBlock->getChildHtml() called at [generated/code/Magento/Catalog/Block/Category/View/Interceptor.php:302]
#35 Magento\Catalog\Block\Category\View\Interceptor->getChildHtml() called at [vendor/magento/module-catalog/Block/Category/View.php:100]
#36 Magento\Catalog\Block\Category\View->getProductListHtml() called at [generated/code/Magento/Catalog/Block/Category/View/Interceptor.php:23]
#37 Magento\Catalog\Block\Category\View\Interceptor->getProductListHtml() called at [vendor/magento/module-catalog/view/frontend/templates/category/products.phtml:15]
#38 include() called at [vendor/magento/framework/View/TemplateEngine/Php.php:71]
#39 Magento\Framework\View\TemplateEngine\Php->render() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#40 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#41 Magento\Framework\View\TemplateEngine\Php\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#42 Magento\Framework\View\TemplateEngine\Php\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/TemplateEngine/Php/Interceptor.php:23]
#43 Magento\Framework\View\TemplateEngine\Php\Interceptor->render() called at [vendor/magento/framework/View/Element/Template.php:263]
#44 Magento\Framework\View\Element\Template->fetchView() called at [generated/code/Magento/Catalog/Block/Category/View/Interceptor.php:140]
#45 Magento\Catalog\Block\Category\View\Interceptor->fetchView() called at [vendor/magento/framework/View/Element/Template.php:293]
#46 Magento\Framework\View\Element\Template->_toHtml() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1095]
#47 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor/magento/framework/View/Element/AbstractBlock.php:1099]
#48 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor/magento/framework/View/Element/AbstractBlock.php:660]
#49 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#50 Magento\Catalog\Block\Category\View\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#51 Magento\Catalog\Block\Category\View\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#52 Magento\Catalog\Block\Category\View\Interceptor->___callPlugins() called at [generated/code/Magento/Catalog/Block/Category/View/Interceptor.php:365]
#53 Magento\Catalog\Block\Category\View\Interceptor->toHtml() called at [vendor/magento/framework/View/Layout.php:578]
#54 Magento\Framework\View\Layout->_renderBlock() called at [vendor/magento/framework/View/Layout.php:555]
#55 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#56 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#57 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#58 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#59 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#60 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#61 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#62 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#63 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#64 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#65 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#66 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#67 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#68 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#69 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#70 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#71 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#72 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#73 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#74 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#75 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#76 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#77 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#78 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#79 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#80 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#81 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#82 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#83 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:606]
#84 Magento\Framework\View\Layout->_renderContainer() called at [vendor/magento/framework/View/Layout.php:557]
#85 Magento\Framework\View\Layout->renderNonCachedElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:149]
#86 Magento\Framework\View\Layout\Interceptor->renderNonCachedElement() called at [vendor/magento/framework/View/Layout.php:510]
#87 Magento\Framework\View\Layout->renderElement() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:140]
#88 Magento\Framework\View\Layout\Interceptor->renderElement() called at [vendor/magento/framework/View/Layout.php:975]
#89 Magento\Framework\View\Layout->getOutput() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#90 Magento\Framework\View\Layout\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#91 Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#92 Magento\Framework\View\Layout\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Layout/Interceptor.php:347]
#93 Magento\Framework\View\Layout\Interceptor->getOutput() called at [vendor/magento/framework/View/Result/Page.php:260]
#94 Magento\Framework\View\Result\Page->render() called at [vendor/magento/framework/View/Result/Layout.php:171]
#95 Magento\Framework\View\Result\Layout->renderResult() called at [vendor/magento/framework/Interception/Interceptor.php:58]
#96 Magento\Framework\View\Result\Page\Interceptor->___callParent() called at [vendor/magento/framework/Interception/Interceptor.php:138]
#97 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}() called at [vendor/magento/framework/Interception/Interceptor.php:153]
#98 Magento\Framework\View\Result\Page\Interceptor->___callPlugins() called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:95]
#99 Magento\Framework\View\Result\Page\Interceptor->renderResult() called at [vendor/magento/framework/App/Http.php:120]
#100 Magento\Framework\App\Http->launch() called at [vendor/magento/framework/App/Bootstrap.php:264]
#101 Magento\Framework\App\Bootstrap->run() called at [pub/index.php:30]```
jfmontanaro commented 1 year ago

(Breaking this into a separate comment because Github didn't like the formatting)

Formatted, that query looks like this:

INSERT INTO `search_tmp_636d2a67d93412_19743921` (`entity_id`, `score`) 
SELECT `main_select`.`entity_id`, SUM(score) AS `relevance` 
FROM (
    SELECT DISTINCT  `search_index`.`entity_id`, (((0) + (0) + (0)) * 1) AS `score` 
    FROM 
        `catalog_product_index_eav` AS `search_index`
        INNER JOIN `cataloginventory_stock_status` AS `stock_index` 
            ON stock_index.product_id = search_index.entity_id 
            AND `stock_index`.`website_id` = 0 
            AND `stock_index`.`stock_id` = 1
        INNER JOIN `catalog_category_product_index_store1` AS `category_ids_index` 
            ON search_index.entity_id = category_ids_index.product_id 
            AND category_ids_index.store_id = '1' 
        WHERE 
            (search_index.store_id = '1') 
            AND (
                `search_index`.`attribute_id` = 99 
                AND `search_index`.`value` in ('2', '4') 
                AND `search_index`.`store_id` = '1'
            ) 
            AND (category_ids_index.category_id in ('10')) 
            AND (`_id_filter`.`_id` NOT IN ('182', '183', '184'))
    ) AS `main_select` 
GROUP BY `entity_id` 
ORDER BY 
    `relevance` DESC, 
    `entity_id` DESC
LIMIT 10000

What's weird to me is that I can't quite figure out what _id_filter.id is referring to. Maybe I'm just misunderstanding the query, but shouldn't that refer to a table or table alias that's referenced somewhere else in the query?

roma84 commented 1 year ago

Hi, it looks like some third-party extension adds this _id_filter part. Maybe you can search the code for _id_filter to find it out? You can use something like:

grep -Hrn "_id_filter" app/code
grep -Hrn "_id_filter" vendor

Also, you can try adding debug_backtrace() in the line where the exception happens.

jfmontanaro commented 1 year ago

Thanks for your response! You are correct, the module interfering was this one: Customer Group Catalog

I tried rolling back to a version of that module that works with Magento 2.3.x, on the grounds that if this module is mimicking the old Magento interface then maybe it can work with that, but no dice. I will have to find another solution.