我想用自定义查询替换magento搜索查询。我在Mysql4 / fulltext.php中尝试但它无法正常工作。
答案 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;