Magento快速搜索 [英] Magento Quick Search

查看:145
本文介绍了Magento快速搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Magento快速搜索时遇到了一个小问题。当我在方框中搜索时说:

制冰机



然后,标题中的所有内容都将被重新标记为 ice machine 。我需要它,因此它只会在标题中搜索具有确切字符串制冰机的产品。

我发现如果我把ice machine加上双重语音标记,它将只返回产品名称所以我需要一种方式,以便自动地在搜索查询周围添加双重语音标记,因此它将搜索整个文本,而不是两个单词分开搜索。

/ p>

有没有一种方法可以以HTML的形式完成这项工作?

解决方案

这个问题多次在MagentoCommerce论坛中报道。 Like搜索逻辑已从AND更改为OR。为了提供更好的结果,需要将其重新更改为AND,以便搜索查询中的所有项目都必须匹配。

搜索Logic Fix core / Mage / CatalogSearch / Model / Mysql4 / Fulltext.php 找到类 public function prepareResult($ object,$ queryText,$ query)



以下一段代码:

  if($ like){
$ likeCond ='('。join('OR',$ like)。')';
}

必须是

  if($ like){
$ likeCond ='('。join('AND',$ like)。')';

$ / code>

创建您自己的重写模块以覆盖此类或通过复制进行覆盖将整个文件Fulltext.php转换为 app / code / local / Mage / CatalogSearch / Model / Mysql4 / Fulltext.php 并将修改为 AND 。该模块是可取的。

I am having a small problem with the Magento quick search. When I search in the box say

ice machine

Then everything will be retuernd where it has ice or machine in the title. I need it so it would just search products with the exact string ice machine in the title.

I found out if I put "ice machine" with the double speech marks it will return only products names that match that exactly.

So I need a way so that the double speech marks get added around the search query automaticlly so it will search the full text not both words seperatly.

Is there a way to do this in the form HTML?

解决方案

This issue is covered over in the MagentoCommerce forums multiple times. The Like search logic was changed from AND to OR. For it to give better results, it needs to be changed back to AND so all items in the search query must match.

Search Logic Fix

In app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php find the class public function prepareResult($object, $queryText, $query)

The following piece of code:

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

needs to be

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

Create your own rewrite module to overwrite just this class or do an override by copying the whole file Fulltext.php over to app/code/local/Mage/CatalogSearch/Model/Mysql4/Fulltext.php and modifying OR to AND. The module is preferable.

这篇关于Magento快速搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆