Post by harleybill » Mon Aug 15, 2011 3:59 am

I have found this dose not affect "description" but ruins "model" "sku' and "tag" search.
Many customers will cut and paste these values. If they pick up a leading or trailing space they will see no results.

Is there a way to remove any spaces front and back.
Last edited by harleybill on Mon Aug 15, 2011 7:30 am, edited 1 time in total.

Harleybill
http://spaparts1.com


User avatar
New member

Posts

Joined
Tue May 04, 2010 7:01 pm


Post by uksitebuilder » Mon Aug 15, 2011 4:39 am

To fix, in catalog/model/catalog/product.php

find:

Code: Select all

	if (isset($data['filter_name']) && $data['filter_name']) {
add after:

Code: Select all

		$data['filter_name'] = trim($data['filter_name']);
find:

Code: Select all

	if (isset($data['filter_name'])) {
add after:

Code: Select all

		$data['filter_name'] = trim($data['filter_name']);

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by harleybill » Mon Aug 15, 2011 6:02 am

Brilliant !
Thank You

Harleybill
http://spaparts1.com


User avatar
New member

Posts

Joined
Tue May 04, 2010 7:01 pm


Post by jakeatencio » Fri Aug 26, 2011 2:19 pm

I really want to add this fix to my site, but I can find any reference to "filter" in the catalog/model/catalog/product.php file. I am using 1.4.9.3. Does this fix apply to this version?

Newbie

Posts

Joined
Fri Apr 29, 2011 5:40 pm

Post by uksitebuilder » Fri Aug 26, 2011 2:47 pm

I believe it's $keyword in 1.4.9.3 (although I only started using OC at 1.5.x)

It's in the same file, but in a different function.

find:

Code: Select all

	public function getProductsByKeyword($keyword, $category_id = 0, $description = FALSE, $model = FALSE, $sort = 'p.sort_order', $order = 'ASC', $start = 0, $limit = 20) {
		if ($keyword) {
add after:

Code: Select all

$keyword = trim($keyword);

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by jakeatencio » Fri Aug 26, 2011 11:25 pm

Thank you for your information. It really seems like this should work, but I get the same wrong results as before. Is there another place I should be looking?

Newbie

Posts

Joined
Fri Apr 29, 2011 5:40 pm

Post by Amuro » Wed Nov 23, 2011 4:17 am

The code for v1.5.1.3 is different. Where lines should I place the trim function for the latest version of opencart?

New member

Posts

Joined
Sat Mar 26, 2011 9:05 am


Post by uksitebuilder » Wed Nov 23, 2011 4:46 am

for 1.5.1.3

edit: catalog/model/catalog/product.php

find 2 ocurrences of

Code: Select all

if (!empty($data['filter_name']) || !empty($data['filter_tag'])) {
add after both occurrences

Code: Select all

$data['filter_name'] = trim($data['filter_name']);

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Amuro » Thu Nov 24, 2011 3:00 am

I put the new codes in both places, but still have the spacing issue. Please go to my website: http://lenobe.com

You can try: 02-AZ-AI98-PCC-RIM with and without space on the header search function. Let me know if you have any insight.

Thanks again.

New member

Posts

Joined
Sat Mar 26, 2011 9:05 am


Post by uksitebuilder » Thu Nov 24, 2011 3:53 am

Hi

Undo the change above

then

edit: catalog/controller/product/search.php

find

Code: Select all

		if (isset($this->request->get['filter_name'])) {
			$filter_name = $this->request->get['filter_name'];
		} else {
			$filter_name = '';
		} 
		
		if (isset($this->request->get['filter_tag'])) {
			$filter_tag = $this->request->get['filter_tag'];
		} elseif (isset($this->request->get['filter_name'])) {
			$filter_tag = $this->request->get['filter_name'];
		} else {
			$filter_tag = '';
		} 
change to

Code: Select all

		if (isset($this->request->get['filter_name'])) {
			$filter_name = trim($this->request->get['filter_name']);
		} else {
			$filter_name = '';
		} 
		
		if (isset($this->request->get['filter_tag'])) {
			$filter_tag = $this->request->get['filter_tag'];
		} elseif (isset($this->request->get['filter_name'])) {
			$filter_tag = trim($this->request->get['filter_name']);
		} else {
			$filter_tag = '';
		} 

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Amuro » Thu Nov 24, 2011 4:11 am

This new change works perfectly! Thanks!

New member

Posts

Joined
Sat Mar 26, 2011 9:05 am

Who is online

Users browsing this forum: Ahrefs [Bot] and 44 guests