码迷,mamicode.com
首页 > 其他好文 > 详细

快速搜索变高级搜索,快速搜索结果准确率提高

时间:2014-10-16 14:30:32      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   os   ar   for   strong   文件   

在MAGENTO的快速搜索中往往得不到好的结果,要嘛是查询不到产品,要嘛是所有产品都列出来,不像高级搜索结果那样理想。 有没有把快速搜索效率提高到高级搜索那个水平呢,可以按下面方法做:

  • Do a full DB backup (just in case) (以下操作万一出现问题了,能够还原,最好第一步就是备份数据库及要目录下的APP文件夹。)
  • Replace “OR” with “AND” app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php at line 331 and 355. (修改此处文件的这二行, OR 改为 AND,注意大小写)
    • model rewrite through our custom module (more preferable)
    • placing the app/code/core/Mage/CatalogSearch/Model/Resource/Fulltext.php into app/code/local/Mage/CatalogSearch/Model/Resource/Fulltext.php (faster approach, less preferable) (复制此处文件到这个文件夹)
  • Go into database then run: (进入MYSQL数据库,运行以下SQL语句)
    UPDATE catalog_eav_attribute SET is_searchable = 0;
     

    This will set all product attributes to “Use in Quick Search” => NO.

  • Go into database then run:(进入MYSQL数据库,运行以下SQL语句)
    UPDATE catalog_eav_attribute SET is_searchable = 1 WHERE attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = "name" AND entity_type_id = (SELECT entity_type_id FROM eav_entity_type WHERE entity_type_code = "catalog_product"));

    This will set only the “name” attribute to “Use in Quick Search” => YES, which is sort of the whole point of this article, having one or minimal set of searchable attributes to get more precise result set.

  • Go into database then run:(进入MYSQL数据库,运行以下SQL语句,此命令会删除以前建好的搜索条件/search terms,也可以不进行删除)
    DELETE FROM catalogsearch_query; DELETE FROM catalogsearch_fulltext;

    This will clear all previously built search query.

  • Go into Magento admin, then do a full reindex (actually only Catalog Search Index is relevant for this). (重建索行)

You can easily make an extension for switching Magento between its OR and your AND statement, have it exposed as configuration value under System > Configuration > Catalog > Catalog > Catalog Search > OR/AND.(此处可以修改搜索条件为OR还是AND,也就是LIKE/FULLTXT,试试会有不同结果)

Hope this helps.

快速搜索变高级搜索,快速搜索结果准确率提高

标签:style   blog   color   io   os   ar   for   strong   文件   

原文地址:http://www.cnblogs.com/qq9915072/p/4028523.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!