first of all I have to say that I'm not that good of a php programmer. I have to upgrade my sites search for it to work like this:
Lets say someone is searching for a product and they write FG-54 and there are tens of products that apply to this search, but some products are written like this: FG54555 and FG 54666, so I have to make the search understand that it should ignore spaces, dashes to search for a product. There are about 700 products in my website so it would be a waste of time to change descriptions of them. Please help!
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Can you clarify that a little?Kipras wrote:Thank you for your reply, but it did not help. Any other suggestions?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
if (!empty($data['filter_description'])) {
$filter_name_exploded = explode(' ', trim($data['filter_name']));
foreach ($filter_name_exploded as $fne) {
if (strlen(trim($fne)) > 1) {
$sql .= " OR (`pd`.`description` = REPLACE(`pd`.`description`, ' ', '')) OR (`pd`.`description` = REPLACE(`pd`.`description`, '-', '')) OR (`pd`.`description` LIKE '%" . $this->db->escape($fne) . "%')";
}
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
It works, thank you so much!straightlight wrote:Try this version to see if it removes the spaces and dashes along:
Code: Select all
if (!empty($data['filter_description'])) { $filter_name_exploded = explode(' ', trim($data['filter_name'])); foreach ($filter_name_exploded as $fne) { if (strlen(trim($fne)) > 1) { $sql .= " OR (`pd`.`description` = REPLACE(`pd`.`description`, ' ', '')) OR (`pd`.`description` = REPLACE(`pd`.`description`, '-', '')) OR (`pd`.`description` LIKE '%" . $this->db->escape($fne) . "%')"; } } }
No problem, enjoy.Kipras wrote:It works, thank you so much!straightlight wrote:Try this version to see if it removes the spaces and dashes along:
Code: Select all
if (!empty($data['filter_description'])) { $filter_name_exploded = explode(' ', trim($data['filter_name'])); foreach ($filter_name_exploded as $fne) { if (strlen(trim($fne)) > 1) { $sql .= " OR (`pd`.`description` = REPLACE(`pd`.`description`, ' ', '')) OR (`pd`.`description` = REPLACE(`pd`.`description`, '-', '')) OR (`pd`.`description` LIKE '%" . $this->db->escape($fne) . "%')"; } } }
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
$filter_name_exploded = explode(' ', trim($data['filter_name']));
foreach ($filter_name_exploded as $fne) {
if (strlen(trim($fne)) > 1) {
$sql .= " OR (`pd`.`description` = REPLACE(`pd`.`description`, ' ', '')) OR (`pd`.`description` = REPLACE(`pd`.`description`, '-', '')) OR (`pd`.`description` LIKE '%" . $this->db->escape($fne) . "%')";
}
}
}
can anyone have another solution it isn't work for me my opencart version is 3.0.2.0.
Lack. If it works for one user but not for you, it means you did something wrong or you're using an extension that prevents this code to work.shwetabv wrote: ↑Fri Dec 24, 2021 7:23 pmif (!empty($data['filter_description'])) {
$filter_name_exploded = explode(' ', trim($data['filter_name']));
foreach ($filter_name_exploded as $fne) {
if (strlen(trim($fne)) > 1) {
$sql .= " OR (`pd`.`description` = REPLACE(`pd`.`description`, ' ', '')) OR (`pd`.`description` = REPLACE(`pd`.`description`, '-', '')) OR (`pd`.`description` LIKE '%" . $this->db->escape($fne) . "%')";
}
}
}
can anyone have another solution it isn't work for me my opencart version is 3.0.2.0.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Maybe you din't refreshed ocmod modification, cleared theme cache, sass cache...
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
If by clearing your cache still doesn't do the trick, you could also create a new service request in the Commercial Support section of the forum, or contact me directly to the forum PM, to have this issue investigated as a custom job.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Users browsing this forum: No registered users and 3 guests