[英]Where is the code that passes the search term to solr search engine in Magento
有誰知道將搜索詞傳遞給Magento中的solr搜索引擎的代碼。 例如,當您在前端的搜索欄中搜索“蜘蛛俠”時,將此搜索詞傳遞給solr搜索引擎或magento默認全文的代碼,模板文件,模塊和php類在哪里?搜索金雞菊。
找到此代碼后,我就放養了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();
}
}
在文件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
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.