【问题标题】:Where is the code that passes the search term to solr search engine in MagentoMagento中将搜索词传递给solr搜索引擎的代码在哪里
【发布时间】:2013-09-24 18:51:45
【问题描述】:

有谁知道将搜索词传递给 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();
    }
}

【问题讨论】:

  • 您使用的是开源 (CE) 版还是商业版(企业版)?默认情况下,开源/社区版不调用 solr,尽管您可以下载 Magentix Solr 的东西(有一些问题,请注意许多分支),这里 github.com/magentix/Solr
  • 我使用的是企业版 1.12
  • 对不起,我还没有看过企业版的东西。我不认为我们可以看到企业版中的所有代码?也许只是它与 CE 版本的共同点?所以我怀疑 Solr 特定的集成代码不会完全可见?

标签: magento search solr


【解决方案1】:

在文件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
    );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-31
    • 1970-01-01
    • 2023-01-30
    • 1970-01-01
    相关资源
    最近更新 更多