I was trying to debug the search query. Temporarily I changed the _getProductCollection method in vendor/magento/module-catalog-search/Block/Result.php .

I notice the query string contains some virtual memory tables like temp_db7..., search_tmp_5d9.. which do not exist in the database. Are there any ways to print the query without virtual tables or debugging processes to know what exactly returned from the database? Any help would be appreciated. Thank You.

SELECT `e`.*, `stock_status_index`.`stock_status` AS `is_salable`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price`, `cat_index`.`position` AS `cat_index_position` FROM `catalog_product_entity` AS `e`
 INNER JOIN `cataloginventory_stock_status` AS `stock_status_index` ON e.entity_id = stock_status_index.product_id AND stock_status_index.website_id = 0 AND stock_status_index.stock_id = 1
 INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0
 INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id='1' AND cat_index.visibility IN(3, 4) AND cat_index.category_id='2'
 INNER JOIN `temp_db7f68ddb4b3ed1441588c3557b0c19a2835876f` AS `product_id_filter` ON `e`.`entity_id` = `product_id_filter`.`entity_id`
 INNER JOIN `search_tmp_5d96cbb832b505_33637111` AS `search_result` ON e.entity_id = search_result.entity_id WHERE (stock_status_index.stock_status = 1) ORDER BY `e`.`entity_id` DESC, `e`.`entity_id` ASC
 LIMIT 240
有帮助吗?

解决方案

Just make your table not TEMPORARY directly in the core (vendor) for testing reasons:

\Magento\Framework\DB\Adapter\Pdo\Mysql::createTemporaryTable

Near row 2169 just remove the word TEMPORARY. Be aware Magento will create a new table for each request and you will need to remove them manually. Don't forget to revert back your core changes.

许可以下: CC-BY-SA归因
scroll top