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 188.8.131.52
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 184.108.40.206.
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' => '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:
Modify the code as described in step 1, save and upload the file to server and you’re done!
In newer versions of OpenCart the
true setting may not do the trick. Then you should try the following:
'filter_description' => $description=1