按类别名称搜索 [英] Search by category name

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

问题描述

当我尝试按类别名称进行搜索时,它不会重复任何内容.例如,我有有机,独特,腐烂等类别,并在搜索中输入独特.但是我没有结果.

When I try to do search by Category Name it reurns nothing. For Eg, I have Organic, Unique, Sprots etc.as categories and in search I type Unique. But I get no results.

推荐答案

不幸的是,Magento的默认搜索功能是产品搜索,并且仅限于该范围.当您搜索唯一"时,它会根据您的配置查找产品名称或说明.

Unfortunately, Magento's default search function is a product search and is limited to that scope. When you search "Unique" it's looking in the products name and perhaps the description depending on your configuration.

一种快速的解决方案是显示匹配类别的列表以及产品结果.

A quick solution would be to display a listing of matching categories along with the product results.

<?php
    $searchTerm = $this->helper('catalogSearch')->getEscapedQueryText();
    $categories = $this->helper('catalog/category')->getStoreCategories(false, true);
    $count = 0;
    foreach ($categories as $count_category) {
        if ($this->helper('catalog/category')->canShow($count_category) && stripos($count_category->getName(), $searchTerm) !== false) 
               $count++;
    }

    if ($count > 0):

    echo "<div class=\"search-term-notice\">";
    echo "The following product categories matched your search:";

    foreach ($categories as $category) {
        if ($this->helper('catalog/category')->canShow($category) && stripos($category->getName(), $searchTerm) !== false) 
            echo "<h3> > <a href='".$category->getUrl()."'>".$category->getName()."</a></h3></p>";
    }
    echo "</div>";
    endif;?>

来源: http://www.magentocommerce.com/boards/viewthread/74632/

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

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