Magento全文搜索错误

时间:2015-11-29 23:02:10

标签: mysql magento search syntax magento-1.8

当我将Magento搜索模式更改为全文或组合时,我收到以下错误消息:

There has been an error processing your request
SQL ERROR: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

SQL QUERY:SELECT 6406 AS `query_id`, `s`.`product_id`, MATCH (s.data_index) AGAINST (:query IN BOOLEAN MODE) AS `relevance` FROM `catalogsearch_fulltext` AS `s`
 INNER JOIN `catalog_product_entity` AS `e` ON e.entity_id = s.product_id WHERE (s.store_id = 1) AND (MATCH (s.data_index) AGAINST (:query IN BOOLEAN MODE))

Trace:
#0 /home/omit/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/omit/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/omit/public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /home/omit/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT 6406 AS ...', Array)
#4 /home/omit/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT 6406 AS ...', Array)
#5 /home/omit/public_html/app/code/local/Mage/CatalogSearch/Model/Resource/Fulltext.php(385): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select))
#6 /home/omit/public_html/app/code/core/Mage/CatalogSearch/Model/Fulltext.php(136): Mage_CatalogSearch_Model_Resource_Fulltext->prepareResult(Object(Mage_CatalogSearch_Model_Fulltext), 'plastic', Object(Mage_CatalogSearch_Model_Query))
#7 /home/omit/public_html/app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext/Collection.php(55): Mage_CatalogSearch_Model_Fulltext->prepareResult()
#8 /home/omit/public_html/app/code/local/Sns/Ajaxfilter/Model/Catalogsearch/Layer.php(77): Mage_CatalogSearch_Model_Resource_Fulltext_Collection->addSearchFilter('plastic')
#9 /home/omit/public_html/app/code/core/Mage/CatalogSearch/Model/Layer.php(42): Sns_Ajaxfilter_Model_Catalogsearch_Layer->prepareProductCollection(Object(Netzarbeiter_GroupsCatalog2_Model_CatalogSearch_Resource_Fulltext_Collection))
#10 /home/omit/public_html/app/code/core/Mage/Catalog/Model/Layer.php(290): Mage_CatalogSearch_Model_Layer->getProductCollection()
#11 /home/omit/public_html/app/code/core/Mage/Catalog/Model/Layer.php(220): Mage_Catalog_Model_Layer->_getSetIds()
#12 /home/omit/public_html/app/code/core/Mage/Catalog/Block/Layer/View.php(163): Mage_Catalog_Model_Layer->getFilterableAttributes()
#13 /home/omit/public_html/app/code/core/Mage/Catalog/Block/Layer/View.php(122): Mage_Catalog_Block_Layer_View->_getFilterableAttributes()
#14 /home/omit/public_html/app/code/core/Mage/Core/Block/Abstract.php(293): Mage_Catalog_Block_Layer_View->_prepareLayout()
#15 /home/omit/public_html/app/code/core/Mage/Core/Model/Layout.php(456): Mage_Core_Block_Abstract->setLayout(Object(Mage_Core_Model_Layout))
#16 /home/omit/public_html/app/code/core/Mage/Core/Model/Layout.php(472): Mage_Core_Model_Layout->createBlock('catalogsearch/l...', 'catalogsearch.l...')
#17 /home/omit/public_html/app/code/core/Mage/Core/Model/Layout.php(239): Mage_Core_Model_Layout->addBlock('catalogsearch/l...', 'catalogsearch.l...')
#18 /home/omit/public_html/app/code/core/Mage/Core/Model/Layout.php(205): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#19 /home/omit/public_html/app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#20 /home/omit/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#21 /home/omit/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(269): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#22 /home/omit/public_html/app/code/local/Sns/Ajaxfilter/controllers/CatalogSearch/ResultController.php(191): Mage_Core_Controller_Varien_Action->loadLayout()
#23 /home/omit/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Sns_Ajaxfilter_CatalogSearch_ResultController->indexAction()
#24 /home/omit/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('index')
#25 /home/omit/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->(Object(Mage_Core_Controller_Request_Http))
#26 /home/omit/public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#27 /home/omit/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#28 /home/omit/public_html/index.php(91): Mage::run('', 'store')
#29 {main}

当我在phpMyAdmin中执行相同的查询时,我得到以下内容:

 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':query IN BOOLEAN MODE) AS `relevance` FROM `catalogsearch_fulltext` AS `s` INN' at line 1

知道这里发生了什么吗?

1 个答案:

答案 0 :(得分:1)

我没有调试代码,但我可以看到错误是由于  $adapter->query($sql, $bind);

$bindnull或空数组()。 但是,我认为$bind不具备这些价值,请查看Mage_CatalogSearch_Model_Resource_Helper_Mysql4函数prepareTerms

我可以看到你重写了/app/code/local/Mage/CatalogSearch/Model/Resource/Fulltext.php。我的猜测是那个课程的问题。