tags:

views:

11

answers:

1

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.

A: 

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;?>

Source: http://www.magentocommerce.com/boards/viewthread/74632/

KThompson