有没有人知道将搜索词传递给Magento中的solr搜索引擎的代码。例如,当您在前端的搜索栏中搜索“spider man”时,代码,模板文件,模块以及将此搜索词传递给solr搜索引擎或magento默认全文的php类在哪里搜索engeine。
找到此代码后,我找到了备货,app / code / core / Mage / CatalogSearch / controllers / ResultController.php
/**
* Display search result
*/
public function indexAction()
{
$query = Mage::helper('catalogsearch')->getQuery();
/* @var $query Mage_CatalogSearch_Model_Query */
$query->setStoreId(Mage::app()->getStore()->getId());
if ($query->getQueryText() != '') {
if (Mage::helper('catalogsearch')->isMinQueryLength()) {
$query->setId(0)
->setIsActive(1)
->setIsProcessed(1);
}
else {
if ($query->getId()) {
$query->setPopularity($query->getPopularity()+1);
}
else {
$query->setPopularity(1);
}
if ($query->getRedirect()){
$query->save();
$this->getResponse()->setRedirect($query->getRedirect());
return;
}
else {
$query->prepare();
}
}
Mage::helper('catalogsearch')->checkNotes();
$this->loadLayout();
$this->_initLayoutMessages('catalog/session');
$this->_initLayoutMessages('checkout/session');
$this->renderLayout();
if (!Mage::helper('catalogsearch')->isMinQueryLength()) {
$query->save();
}
}
else {
$this->_redirectReferer();
}
}
答案 0 :(得分:0)
在 app / code / core / Enterprise / Search / Model / Adapter / HttpStream.php 文件中 功能是:
protected function _search($query, $params = array())
将查询发送到solr的行:
$response = $this->_client->search(
$searchConditions, $offset, $limit, $searchParams, Apache_Solr_Service::METHOD_POST
);