Post by case42 » Sun Dec 18, 2011 8:49 am

Hi there - I'm new to OpenCart, but not a programming dummy - I'm familiar enough with OC and proficient enough with PHP to understand modification techniques - I've done quite a bit myself, but I'm having some difficulty adding "sku" to the search function - I don't need to add a choice, just have the search function always search in sku field, as well. help? I have version 1.4.x - not sure the exact version.

Newbie

Posts

Joined
Thu Dec 08, 2011 5:59 am

Post by Qphoria » Mon Dec 19, 2011 12:12 am

(v1.5.1.3)
1. EDIT: catalog/model/catalog/product.php

2. FIND (4 times) EXACTLY:

Code: Select all

LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'
3. GLOBAL REPLACE WITH:

Code: Select all

LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by straightlight » Mon Dec 19, 2011 3:13 am

I'm seeing twice the pd.name field in the LCASE ...

I believe it would be:

Code: Select all

LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'
to search by product name or product sku.

For models along with the product name and sku, it would be like:

Code: Select all

LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.sku) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%' OR LCASE(p.model) LIKE '%" . $this->db->escape(utf8_strtolower($word)) . "%'
for future reference.

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 case42 » Tue Dec 20, 2011 2:56 am

the second one, (by straightlight ) worked with some modifications
1) the function "utf8_strtolower" had to be changed to "strtolower" and
2) $word is $keyword

so, now to find the same deal for admin searches... erg....

Thanks to both of you very much for the help - a quick pointer to finding this search in admin would be more then gracious of you....

Newbie

Posts

Joined
Thu Dec 08, 2011 5:59 am

Post by Qphoria » Tue Dec 20, 2011 3:20 am

Thanks straightlight.. i got a bit quick with my copy/paste :P
Updated

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by case42 » Tue Dec 20, 2011 3:24 am

Anyone want to offer a quick pointer to the same search functionality in admin?

Newbie

Posts

Joined
Thu Dec 08, 2011 5:59 am
Who is online

Users browsing this forum: No registered users and 18 guests