In some instances, it's useful to override and modify the sitewide search block to search only eCommerce product titles and return only products. Here is a good way to achieve that:
First, you need override your search block (copy the search block directory from the core and place a copy of it into your override block directory in the site root) and make some modifications to the controller.php file.
Within the:
function do_search()
find the following:
$ipl->setSimpleIndexMode(true);
if (isset($_REQUEST['query'])) {
$ipl->filterByKeywords($_q);
}
and modify it like so:
$ipl->setSimpleIndexMode(true);
if (isset($_REQUEST['query'])) {
//$ipl->filterByKeywords($_q);
$ipl->filterByName($_q);
}
$ipl->filterByCollectionTypeHandle('product_detail');
Note: You need to make sure your products are set to have their own pages in order for this to work.
There you go! Now your search only looks through product names and returns only product pages.
Loading Conversation