I am associating my products with categories in Magento, and I'd like to modify the basic search so that products from category names that match the search query are included in the results.

Is there a buried option that allows that? Category is not an attribute as such, and I can't find an option in each category to include in search.

  • Is problem solved ?
    – inrsaurabh
    Commented Jun 9, 2018 at 16:11

1 Answer 1


There is no out of the box way of doing this, but you can trick magento into doing this.
You can create a hidden attribute called category_names that is seachable but not displayed in the frontend.
Then create an observer for the catalog_product_save_before where you take all the category names from the associated categories and place them in this field.
Something like this (untested):

public function setCategoryNames($observer)
    $product = $observer->getProduct();
    $categoryIds = $product->getCategoryIds();
    $storeId = $product->getStoreId();
    $categories = Mage::getModel('catalog/category')->getCollection()
                ->addAttributeToFilter('entity_id', $categoryIds)
    $names = array();
    foreach ($categories as $category) {
        $names[] = $category->getName();
    $product->setCategoryNames(implode(' ', $names));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.