How do I modify search.php so all of my searches look through descriptions too?
Basically, I just want the below box to be 'ticked' all the time, rather than me manually ticking it.
https://postimg.org/image/ihre7tzw7/
There's a few old posts, I'm running OpenCart 2.0.1.1
Thanks
You could edit catalog/view/theme/YOUR_THEME/template/product/search.tpl and find
And change it to
Code: Select all
<label class="checkbox-inline">
<?php if ($description) { ?>
<input type="checkbox" name="description" value="1" id="description" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="description" value="1" id="description" />
<?php } ?>
<?php echo $entry_description; ?></label>
Code: Select all
<label class="checkbox-inline">
<input type="checkbox" name="description" value="1" id="description" checked="checked" />
<?php echo $entry_description; ?></label>
Following your advice, it changes the view only.
Search by descriptions still is not performed by default.
Search by descriptions still is not performed by default.
If you want to have search in descriptions box checked all the time when doing search in opencart then you need to follow the instructions below ( ive tried and tested it and it works)
Modify the search.php for version 2 and less
Find the search.php file located in: catalog/controller/product/search.php
Locate this code below:
$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 'filter_description' => 'true',
Above is for Opencart ver 2
-----------------------------------------------------------------------------------------------------------------------------------
For Version 3 follow the instructions below
For Opencart version 3 ( I have this and I changed it to the below code and it worked . I see the check box in Search in product descriptions always when doing search )
change the code to below
'filter_description' => $description=1
Thats it and save. Please do make a backup copy of the code just in case but this works for me and i use Opencart 3.0.3.6 version
Modify the search.php for version 2 and less
Find the search.php file located in: catalog/controller/product/search.php
Locate this code below:
$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 'filter_description' => 'true',
Above is for Opencart ver 2
-----------------------------------------------------------------------------------------------------------------------------------
For Version 3 follow the instructions below
For Opencart version 3 ( I have this and I changed it to the below code and it worked . I see the check box in Search in product descriptions always when doing search )
change the code to below
'filter_description' => $description=1
Thats it and save. Please do make a backup copy of the code just in case but this works for me and i use Opencart 3.0.3.6 version
Thanks guys!
I made a quick ocmod extension that changes it to include description. Also, while I was at it, removed the need to check in seatrch from subcategories.
And removed the checkboxes + texts from twig files.
Posted the extension here:
https://www.opencart.com/index.php?rout ... n_id=44888
Cheers!
Who is online
Users browsing this forum: No registered users and 305 guests