Post by Kipras » Wed Aug 10, 2016 6:00 pm

Hello,
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!

Newbie

Posts

Joined
Thu Jul 14, 2016 10:39 pm

Post by straightlight » Wed Aug 10, 2016 7:56 pm

Followed is a tweak that could fit your requirements: http://forum.opencart.com/viewtopic.php ... ch#p586604

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kipras » Wed Aug 10, 2016 9:09 pm

Thank you for your reply, but it did not help. Any other suggestions?

Newbie

Posts

Joined
Thu Jul 14, 2016 10:39 pm

Post by straightlight » Wed Aug 10, 2016 9:16 pm

Kipras wrote:Thank you for your reply, but it did not help. Any other suggestions?
Can you clarify that a little?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kipras » Wed Aug 10, 2016 9:32 pm

It did not ignore dashes and spaces in the product description.
Last edited by Kipras on Wed Aug 10, 2016 9:42 pm, edited 1 time in total.

Newbie

Posts

Joined
Thu Jul 14, 2016 10:39 pm

Post by straightlight » Wed Aug 10, 2016 9:40 pm

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Kipras » Wed Aug 10, 2016 9:43 pm

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) . "%')";
                                                }
               }
            }
It works, thank you so much!

Newbie

Posts

Joined
Thu Jul 14, 2016 10:39 pm

Post by straightlight » Wed Aug 10, 2016 9:44 pm

Kipras wrote:
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) . "%')";
                                                }
               }
            }
It works, thank you so much!
No problem, enjoy.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by shwetabv » Fri Dec 24, 2021 7:23 pm

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) . "%')";
}
}
}


can anyone have another solution it isn't work for me my opencart version is 3.0.2.0.

Newbie

Posts

Joined
Fri Dec 24, 2021 7:15 pm

Post by straightlight » Sat Dec 25, 2021 11:00 pm

shwetabv wrote:
Fri Dec 24, 2021 7:23 pm
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) . "%')";
}
}
}


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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by shwetabv » Mon Dec 27, 2021 4:38 pm

how should i now where is wrong now be its urgent i have more than 3k product on my side is have any another solution

Newbie

Posts

Joined
Fri Dec 24, 2021 7:15 pm

Post by xxvirusxx » Mon Dec 27, 2021 5:10 pm

shwetabv wrote:
Mon Dec 27, 2021 4:38 pm
how should i now where is wrong
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


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by straightlight » Tue Dec 28, 2021 12:45 am

shwetabv wrote:
Mon Dec 27, 2021 4:38 pm
how should i now where is wrong now be its urgent i have more than 3k product on my side is have any another solution
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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by shwetabv » Sat Jan 01, 2022 1:58 pm

i am new in opencart how should i create a new service request in the Commercial Support section of the forum

Newbie

Posts

Joined
Fri Dec 24, 2021 7:15 pm

Post by xxvirusxx » Sat Jan 01, 2022 8:23 pm

shwetabv wrote:
Sat Jan 01, 2022 1:58 pm
how should i create a new service request in the Commercial Support section of the forum
You can post here
viewforum.php?f=88

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: No registered users and 3 guests