Page 1 of 1

Partial Search in Model (product code)

Posted: Wed Dec 17, 2014 9:18 pm
by tyfricko
Hello everyone,

I have product codes like this:
GWA001
GWA002
GWA...
then
GWB001
GWB003
and so on

My customers have paper catalogues, so when they search on my site they only search for words GWA or GWB,
I want that when someone searches GWA the script displays only GWA articles.
How I do that?

I use v1.5.5.1

Thank you all.

Re: Partial Search in Model (product code)

Posted: Thu Dec 18, 2014 5:12 pm
by tyfricko
I don't know how I do it but I have luck and now works.
i have changed some code to: catalog/model/catalog/product.php

I replaced this lane:

Code: Select all

$sql .= " OR LCASE(p.model) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
With this line:

Code: Select all

$sql .= " OR p.model LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
and you have to do it 2 times first on line 141 and second on line 542.

Hope will help someone else ;)

Re: Partial Search in Model (product code)

Posted: Wed Feb 25, 2015 1:32 am
by michaelsen
Thank you!!
This also works in opencart 2.0. I am using 2.0.1.1.
Just throwing that in here in case someone else is searching for a solution to get search results from a partial model number search

Re: Partial Search in Model (product code)

Posted: Fri Jan 13, 2017 5:05 pm
by davidmorrison
Hi All,

I am experiencing two issues with my search on my storefront.

I have product codes (Models) containing forward slash, hyphen and full stop (period). If I enter AQST52/13 for example...the search results displays the correct product at the top of the search results. However, the results also display any other product with "/13".

Ideally, I would like that when the user inputs a product code, then only that product will display as a result or if the user enters "AQST" then all products with that attribute are displayed. I believe the issue is with the values after the forward slash, hyphen or full stop.

The other problem I have is that if the user enters the product code in the incorrect case...then the product is not being listed as the first result but is instead being displayed further down the page.

Other than that, if a user searches by product name the search works well...but in the industry product codes are key.

To recap:

1.I would like case sensitivity turned off in relation to search by model

2.I require assistance in relation to product codes containing /,- and .

Please help....