Page 1 of 1

Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Nov 22, 2019 1:58 am
by alexanderaldev
Hello there :)
I am using opencart 3.0.3.2 with Journal 3 and I have problem with seach products when i use SKU number.
There is a product in Catalog with SKU with number 50131001B - when i search it everything is fine, but when i try to search with only part of that SKU for example 50131001 or 50131 search results show me that there is no products with this matching criteria. Is there anyway to change that "exact match" with logic to search even i've entered a part of it.
Thanks in advanced to everyone :)

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Nov 22, 2019 2:59 am
by letxobnav
catalog/model/catalog/product.php function getProducts()

Code: Select all

$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "'";
change to

Code: Select all

$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Nov 22, 2019 4:47 pm
by alexanderaldev
Thanks for hepling me, but still doesn't appear the result https://iprotect.bg/index.php?route=pro ... ption=true but when it's full SKU it appear - https://iprotect.bg/index.php?route=pro ... ption=true

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Nov 22, 2019 5:53 pm
by JNeuhoff
Try the suggested modification with the Journal theme disabled, e.g. with OpenCart's default theme. The Journal software clashes with a lot of other 3rd party extensions or modifications, and it might possibly use its own model class instead of the one modified by you.

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Nov 22, 2019 7:18 pm
by letxobnav
I forgot, getTotalProducts()

same change, you have to keep these two functions in sync.

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Sat Nov 23, 2019 7:17 pm
by alexanderaldev
Yeah Journal obviously use own logic for search because that functuality i'm looking for is already code in auto-suggest
I've disabled and also change both methods in catalog/product.php with

Code: Select all

$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
Delete all cache and refresh modifications
But still product doesn't appear in search without B in the sku :(

Ok .. i change the SKU to Model .. trying to do the same with the model with like '%" method but still nothing

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Sat Nov 23, 2019 9:10 pm
by xxvirusxx
Try this

Code: Select all

$sql .= " OR LCASE(p.sku) LIKE '%" . str_replace(' ', "%' OR LCASE (p.sku) LIKE '%", $data['filter_name']) . "%'";

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Sat Nov 23, 2019 9:14 pm
by letxobnav
why not put

Code: Select all

error_log($sql);
or

Code: Select all

$this->log->write($sql);
at the bottom of function getProducts()

just before

Code: Select all

$query = $this->db->query($sql);
then you can see which query is executed.

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Wed Feb 17, 2021 6:53 pm
by aitechbg
None of above is working for Journal 3x

This one is though:
find around line 995 in /catalog/model/journal3/filter.php
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($filter_data['filter_name'])) . "'";
and change to
$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($filter_data['filter_name'])) . "%'";

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Wed Feb 17, 2021 9:25 pm
by straightlight
aitechbg wrote:
Wed Feb 17, 2021 6:53 pm
None of above is working for Journal 3x

This one is though:
find around line 995 in /catalog/model/journal3/filter.php
$sql .= " OR LCASE(p.sku) = '" . $this->db->escape(utf8_strtolower($filter_data['filter_name'])) . "'";
and change to
$sql .= " OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($filter_data['filter_name'])) . "%'";
While the OC version has been unposted, Journal is unsupported on the forum in anyhow. Please contact Journal support for further assistance with Journal requests.

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Thu Mar 20, 2025 11:01 pm
by VanioBoy
In order not to open a new topic, I'm writing here. The platform version is the same.
Can I change the search to 2 or more words?
Example: Currently, if I type zz uu, products containing only one or both words will be displayed, and I want to display only products containing both words.

Re: Search Results for products with part of SKU - Journal 3.0.3.2

Posted: Fri Mar 21, 2025 12:57 am
by JNeuhoff
This forum thread is several years old, and the OP probably has resolved the issue since then.

Besides, this forum is for OpenCart, for Journal3 use their support. The Journal3 framework uses its own search functionality anyway. Also, we strongly recommend to use a proper standard-compliant web theme for OpenCart, not a different framework like Journal.