Search in product descriptions by default

Many visitors of E-commerce websites use the search to find something of interest and if they spell the keywords wrong the search results will often return a blank result page. Moreover, the default OpenCart search doesn’t look within the product description unless you check the box to do so. But what if I want this to be active as default option? Learn how to activate search in product descriptions by default in OpenCart 2.3.0.2

The search engine in OpenCart is fairly simple and by default it searches only by the product name. Once you get the search results page you get the option to search further within product description and subcategories if you like to.

Since it is not good practise for the customers to get blank search results page it is cool to activate the option search in product descriptions by default. In my case this is the trick I used on OpenCart version 2.3.0.2.

1. Modify the search.php

Find the search.php file located in: catalog/controller/product/search.php
Locate the code:


$filter_data = array(
            'filter_name'         => $search,
            'filter_tag'          => $tag,
            'filter_description'  => $description,
            'filter_category_id'  => $category_id,
            'filter_sub_category' => $sub_category,
            'sort'                => $sort,
            'order'               => $order,
            'start'               => ($page - 1) * $limit,
            'limit'               => $limit
        );

Change the line filter_description to:

'filter_description'  => 'true',

Save and upload the file back to the server and you are done!

In case you are using some third-party extensions/modules and you don’t see the changes you just made in search.php file then proceed to next step.

2. Modify the search.php

For those who are using extensions or custom themes which have done some modifications to default search.php file then the previous step 1 needs to be done also in the same file but on different location:

/system/storage/modification/catalog/controller/product/search.php

Modify the code as described in step 1, save and upload the file to server and you’re done!

Known issues

In newer versions of OpenCart the true setting may not do the trick. Then you should try the following:

'filter_description'  => $description=1

By janoshke

Web developer and IT consultant. Freelancer with full respect for OpenCart and WordPress. Gamer, (ex)drummer and parent.

8 comments

  1. Thank you very much. $description=1 works for me, but can I ask something?
    Is there a way to start with the description selected by default, but if the user wants to unselect it, they can?
    Because now, if I unselect it and hit search again, it’s reselected. So it’s like the button looses its functionality.

    Thank you again

    1. Hi,
      Thank you for your comment.
      This method is hardcoding the “look within the product description” option so it always stays selected. It is not a good method if you want to leave the option to the visitor to check/uncheck the field. It is always better to educate the visitors on proper website usage then to hardcode something in order to feed their way of thinking.

Leave a ReplyCancel reply

Exit mobile version
%%footer%%