Post by alexanderaldev » Fri Nov 22, 2019 1:58 am

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 :)

https://aldev.bg/


User avatar

Posts

Joined
Thu Oct 24, 2019 4:05 pm
Location - Sofia, Bulgaria

Post by letxobnav » Fri Nov 22, 2019 2:59 am

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

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by alexanderaldev » Fri Nov 22, 2019 4:47 pm

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

https://aldev.bg/


User avatar

Posts

Joined
Thu Oct 24, 2019 4:05 pm
Location - Sofia, Bulgaria

Post by JNeuhoff » Fri Nov 22, 2019 5:53 pm

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.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member
Online

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by letxobnav » Fri Nov 22, 2019 7:18 pm

I forgot, getTotalProducts()

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

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by alexanderaldev » Sat Nov 23, 2019 7:17 pm

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

https://aldev.bg/


User avatar

Posts

Joined
Thu Oct 24, 2019 4:05 pm
Location - Sofia, Bulgaria

Post by xxvirusxx » Sat Nov 23, 2019 9:10 pm

Try this

Code: Select all

$sql .= " OR LCASE(p.sku) LIKE '%" . str_replace(' ', "%' OR LCASE (p.sku) LIKE '%", $data['filter_name']) . "%'";
Last edited by xxvirusxx on Sat Nov 23, 2019 9:22 pm, edited 1 time in total.

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 letxobnav » Sat Nov 23, 2019 9:14 pm

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.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by aitechbg » 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'])) . "%'";

Web Development, Consulting and SEO for Europe by itech.bg


Newbie

Posts

Joined
Mon Mar 27, 2017 8:51 pm

Post by straightlight » Wed Feb 17, 2021 9:25 pm

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.

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
Who is online

Users browsing this forum: Amazon [Bot] and 81 guests