1
votes

I am trying to modify the Magento catalog search result but no luck yet. I've both simple and grouped/ configurable products in the store.

If someone searches for 'searchTerm 1' I want only the parent products to appear that matches the search term, not those products whose child product matches. I cannot set those child product as 'Don't show individually' because I want them to appear individually as well (in case of grouped products )

E.g.

  1. This is Fruit product title. (Grouped Product ) Childs are: a.) This is Mango fruit product title b.) This is Banana fruit product title

  2. This is Mango Juice product title (Grouped Product ) Childs are: a.) This is Mango Juice tetra pack product title b.) This is mango juice another child product title

Now, if I search for Mango, I should only get product #2 i.e. This is Mango Juice product title

2

2 Answers

1
votes

You can change the product visibility for the "Child" products to "Catalog". This way you will still be able to see those products while browsing the categories but they will be ignored on search.
[EDIT]
You may want to take a look at this method: Mage_CatalogSearch_Model_Resource_Fulltext::_rebuildStoreIndex. There is something in there about child products. Try to see if you can ignore them

1
votes

Thanks @Marius, it worked like a charm. I had to comment the following:

 /* Commented by Tanay to remove child product from search result
if ($productChilds = $productRelations[$productData['entity_id']]) {
    foreach ($productChilds as $productChildId) {
        if (isset($productAttributes[$productChildId])) {
            $productIndex[$productChildId] = $productAttributes[$productChildId];
        }
    }
}
*/