Magento搜索引擎相关性问题 [英] Magento Search Engine Relevance Issues

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

问题描述

目前,我们有一个Magento网站,该网站的库存很大,但我们在ON SITE搜索结果的相关性方面存在一些问题.目前,我们设置为像完整文本一样结合",但结果却不是我们期望的.例如,搜索"Lee Child"(作者),将显示三本Lee Child书,然后显示三本作者为"Lauren Child"的书,然后显示其余的Lee Child书.

We currently have a Magento website with a large inventory, we are having some issues with relevance of ON SITE search results. We are currently set to 'combine like and fulltext' but the results are aren't what we expected. For example searching for 'Lee Child' (the author), brings up three Lee Child books, then three books with author as 'Lauren Child' and then the rest of the Lee Child books.

因此,从本质上讲,我们希望优先考虑全文搜索并在类似搜索结果之前查看那些结果.我们还希望在缺货之前显示有现货的产品.

So essentially we want to give preference to the full text search and view those results BEFORE the like search results. We also want to display in stock products before out of stock products.

我们有一个测试服务器,我读了一个论坛帖子,说magento目前正在拆分搜索查询,并显示包含至少一个单词的产品.

We have a test server and I read a forum post that said at the moment magento splits the search query and show products which have at least one of the words.

我们修改了Mage_CatalogSearch_Model_Mysql4_Fulltext的第342行(对于CE1.4.2):

We modified line 342 (for CE1.4.2) of the Mage_CatalogSearch_Model_Mysql4_Fulltext:

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

,然后将"OR"更改为"AND".

and change "OR" with "AND"`

路径:app/code/core/Mage/CatalogSearch/Model/Mysql4/Fulltext.php

这是一个较早版本的修复程序,我们当前正在运行1.5.0.1.

This is a fix for an earlier edition and we are currently running 1.5.0.1.

我是否需要完善与Magento搜索结果相关的内容?或者您可以在代码中向我指出正确的方向吗?

Is there something I'm missing to tinker with the Magento search results relevance or can you point me in the right direction in the code?

推荐答案

我相信缺少的键"是以下两项:

I believe the missing "keys" are the following two items:

<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>

您应该可以通过几种不同的方式来完成此操作……无论哪种情况,都需要在本地创建所述文件的副本.

You should be able to acomplish this a couple different ways... in either case you'll need to make local copies of the said files.

1)如果还没有,请添加'catalogsearch.xml'的本地副本

1) If you don't already have one, add a local copy of 'catalogsearch.xml'

注意: 由于Magento布局是级联"的,因此最好先检查可用的其他" Magento布局目录(而不是基本"目录).例如,在我的情况下,我们使用EE,因此在查看基本"目录之前,我们首先检查企业"布局目录以复制文件.

Note: Since Magento layouts work "cascading" it's a good idea to first check any "other" Magento layout directories available (other than the 'base'). For example, in my case we use EE, so we check the 'enterprise' layout directory first to copy files before looking in the 'base' directory.

"catalogsearch.xml"的常见位置:

Common locations of 'catalogsearch.xml':

/app/design/frontend/base/default/layout/catalogsearch.xml(作为最后的手段) /app/design/frontend/enterprise/default/layout/catalogsearch.xml(适用于EE) 注意:PE可能也位于其他位置...我不是100%.

/app/design/frontend/base/default/layout/catalogsearch.xml (as last resort) /app/design/frontend/enterprise/default/layout/catalogsearch.xml (for EE) Note: There may be a different location with PE as well... I'm not 100%.

2)在"catalogsearch.xml"的"catalogsearch_result_index"部分中添加以下内容:

2) Add the following within the 'catalogsearch_result_index' section in 'catalogsearch.xml':

<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>

例如:

参考"search_result_list"句柄(即企业布局):

Referencing the 'search_result_list' handle (ie enterprise layout):

<reference name="search_result_list">
    <action method="setDefaultDirection"><string>desc</string></action>
    <action method="setDefaultOrder"><string>relevance</string></action>
</reference>

所以它最终看起来类似于:

So it would end up looking similar to:

<catalogsearch_result_index>
...other code

    <reference name="search_result_list">
        <action method="setDefaultDirection"><string>desc</string></action>
        <action method="setDefaultOrder"><string>relevance</string></action>
    </reference>

...other code

</catalogsearch_result_index>

或者您可以直接将其放置在"search_result_list"块中(即基本布局):

Or you can place directly within the 'search_result_list' block (ie base layout):

<catalogsearch_result_index translate="label">
    <label>Quick Search Form</label>
    <reference name="root">
        <action method="setTemplate"><template>page/3columns.phtml</template></action>
    </reference>
    <reference name="left">
        <block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
    </reference>
    <reference name="content">
        <block type="catalogsearch/result" name="search.result" template="catalogsearch/result.phtml">
            <block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">

               <action method="setDefaultDirection"><string>desc</string></action>
               <action method="setDefaultOrder"><string>relevance</string></action>

                <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                    <block type="page/html_pager" name="product_list_toolbar_pager"/>
                </block>
                <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
                <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
            </block>
            <action method="setListOrders"/>
            <action method="setListModes"/>
            <action method="setListCollection"/>
        </block>
    </reference>
</catalogsearch_result_index>

3)确保转储Magento缓存/存储并重新索引.

3) Make sure to dump the Magento cache/storage and reindex.

另一种选择是将它们作为隐藏"表单元素放置在"form.mini.phtml"中

The other option would be to place them as 'hidden' form elements in 'form.mini.phtml'

1)将以下内容放入"form.mini.phtml"中的表单中:

1) Place the following within the form in 'form.mini.phtml':

<input type="hidden" name="order" value="relevance">
<input type="hidden" name="dir" value="desc">

现在,"form.mini.phtml"中表单的开头看起来类似于:

Now, the beginning of the form in 'form.mini.phtml' would look similar to:

<form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
        <input type="hidden" name="order" value="relevance">
        <input type="hidden" name="dir" value="desc">
    ...other code

2)在"catalogsearch.xml"的默认"部分(标题"参考句柄)内,将路径更改为"form.mini.phtml"模板:

2) Change the path to 'form.mini.phtml' template within the 'default' section ('header' reference handle) in 'catalogsearch.xml':

<default>
        <reference name="header">
            <block type="core/template" name="top.search" as="topSearch" template="custom_template/catalogsearch/form.mini.phtml"/>
        </reference>
... other code

3)确保转储Magento缓存/存储并重新索引.

3) Make sure to dump the Magento cache/storage and reindex.

最后的提示... 下面是我们将其设置为自定义模板"的路径结构.位于企业"目录中,因此我的自定义文件位于: /app/design/frontend/enterprise/custom_template/layout/catalogsearch.xml /app/design/frontend/enterprise/custom_template/template/catalogsearch/form.mini.phtml

Final note... Below is the "custom template" path structure we have it setup as. Located in the 'enterprise' directory, so my custom files would be located: /app/design/frontend/enterprise/custom_template/layout/catalogsearch.xml /app/design/frontend/enterprise/custom_template/template/catalogsearch/form.mini.phtml

希望这是有道理的,对您有帮助.

Hope this makes sense and helps.

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

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