Post by scapes » Thu Jun 14, 2012 12:38 pm

I have been trying to get searches for products to work in admin - it seems to only work for an exact match from the start of the product name. So for example, if I search for all my guitar strings products with 'Strings', it only picks up the entries where the first word of the product name is Strings. I really need a way to search so it picks up with a wild card format. upper and lower

Can anyone suggest a solution?

I'm using version the latest version 1.5.3.1

Thanks,
Kevin

Newbie

Posts

Joined
Thu Jun 14, 2012 11:38 am

Post by Avvici » Sat Jun 16, 2012 5:57 am

Hmm, this simple is not true. It works on a partial match too. So say's this:

Code: Select all

if (!empty($data['filter_name'])) {
				$sql .= " AND LCASE(pd.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
			}
I just tested on my own admin. For a product named 'Cannodryer Sheet' is was finding it by typing in the string 'can'

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by scapes » Sat Jun 16, 2012 10:02 am

Yes - that will work for me too if the product name starts with 'Can'. But can you find that product by entering 'Sheet'?

That is the problem I think.

I saw another post where someone said there was a wildcard ability previously, and was taken out in a recent version. I don't mind modifying the code if necessary. But I tried a little without success.

Thanks,
Kevin

Newbie

Posts

Joined
Thu Jun 14, 2012 11:38 am

Post by scapes » Sat Jun 16, 2012 10:16 am

OK, I tried again to fix it and this time it worked :)

At two places in the admin/model/catalog/product.php I added an extra # for wildcard before the variable, where there was already one after it. It fixed the problem.

So the change is from this:

Code: Select all

$sql .= " AND LCASE(pd.name) LIKE '" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
To this:

Code: Select all

$sql .= " AND LCASE(pd.name) LIKE '%" . $this->db->escape(utf8_strtolower($data['filter_name'])) . "%'";
One character added in each of two lines.

Cheers,
Kevin

Newbie

Posts

Joined
Thu Jun 14, 2012 11:38 am

Post by Avvici » Sat Jun 16, 2012 9:48 pm

%varaible% :) And I didn't even have to recommend anything. Cheers. Marking solved.

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by scapes » Sun Jun 17, 2012 2:30 am

oops - yes - % not # :)

Newbie

Posts

Joined
Thu Jun 14, 2012 11:38 am

Post by timeshell » Fri Dec 23, 2016 4:41 am

OR, you could simply type your search string with % before and after it instead of editing the files.

New member

Posts

Joined
Fri Aug 05, 2016 5:49 am
Who is online

Users browsing this forum: No registered users and 7 guests