如何在magento中更改搜索查询?

时间:2015-08-04 17:22:58

标签: magento

我想用自定义查询替换magento搜索查询。我在Mysql4 / fulltext.php中尝试但它无法正常工作。

2 个答案:

答案 0 :(得分:1)

扩展Mage_CatalogSearch_Model_Query并编写一个名为getSynonymFor()的函数,如下所示:

public function getSynonymFor()
{
    //use custom logic to check query text and replace here
    if ($shouldReplace) {
        //find replacement
        return $replacementQuery;
    }
    //otherwise
    return $this->getData('synonym_for');
}

答案 1 :(得分:1)

app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php

变化

$likeCond = '(' . join(' OR ', $like) . ')';

$likeCond = '(' . join(' AND', $like) . ')';

$where .= ($where ? ' OR ' : '') . $likeCond;

$where .= ($where ? ' AND ' : '') . $likeCond;