Post by bthirsk » Sat Nov 01, 2008 1:51 am

I am working on a simple routine to modify the Keyword search string.
It removes spaces and surrounds all words with wildcard characters.
This allows searching by words, not phases.

I would like to know where the best place would be to capture and modify the input string.
I looked at Request (GET)  or in Controller/Search.php

Any suggestions would be appreciated.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by bruce » Sat Nov 01, 2008 7:52 am

catalog\controller\search.php in $session->get('search.search')

in the index function

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by bthirsk » Mon Nov 03, 2008 7:11 am

Thanks
That worked fine. I just placed the following code.
"catalog/controller/search.php"
ADD $session->set('search.search',wildcardsearch(($session->get('search.search')));      (LINE 37)

Everything works great except if you include double quotes eg: 1/2" impact gun
I think the problem may be how FCKeditor designates " as ” instead of &quot,
but I'm not sure.
I tried double quotes without my code, with similar results.
Brent
On further checking, it appears the problem is in Request.
This is what it appears to be sent to query.
1/2" impact gun
Last edited by Anonymous on Mon Nov 03, 2008 7:28 am, edited 1 time in total.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by bruce » Mon Nov 03, 2008 1:11 pm

:D easy, all you have to do is convince your customers to search for 1/2" impact gun
ROFL

On a serious note though. You are correct that fckeditor encodes the character (but as ") and that means your search would not successfully find 1/2" regardless of the other bugs expanding the & sign so many times.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by bthirsk » Mon Nov 03, 2008 7:31 pm

I have the input cleaned up to now produce
%1/2"%%impact%%gun%
It still won't return results.
And as for the FCK, it will product either &rdquo or "
You can tell when viewing generated code, the Quote style is a little different.
I checked about 20 products and some are ” while others are " (I think these is a Source copy problem.)
I changed a couple to &quot and it doesn't seem to care. (I guess FCK puts in what you give it.)

I guess I'll have to check how the SQL is handled to locate the problem.
Thanks
Brent
I checked the SQL backup and these products are correct in data base. " is how " is designated.
It show find these items. Data base query must be stripping Quotes.
Last edited by Anonymous on Mon Nov 03, 2008 8:26 pm, edited 1 time in total.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by bruce » Mon Nov 03, 2008 8:49 pm

Can I suggest a different approach?

Add a keywords field to your product_description table (plus some admin support) and put all the "words" in there, that you want the search to find and include the keywords field in your sql search instead of the product description. A bit more work but less BS than trying to dodge input variations from products and content that you cannot completely control.

cheers

Bruce

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by bthirsk » Mon Nov 03, 2008 10:28 pm

That would be an alternative, but would I not still be faced with the double quote problem.
If I include " in a description, with is very probably what a customer might do, It won't return results
no matter how it is stored.

This is the SQL on one of the products I am testing for.

INSERT INTO `product_description` (`product_id`, `language_id`, `name`, `description`) VALUES ('456', '1', 'JEA_400249', '1/2" Drive Heavy Duty Impact Wrench
\r\nMax.Torque: Forward 480 ft/lbs
\r\nOverall Length: 7-5/8"
\r\nFree Speed RPM: 7,500
\r\nAvg. Air Consumption (CFM): 4.2
\r\nAir Inlet NPT: 1/4"
\r\nMinimum Hose Size: 3/8"
\r\nFor Maximum Performance:
\r\nRecommended Air Pressure 90 PSI\r\n1/2 inch air impact gun');

As you can see, it contains everything in the search term %1/2"%%impact%%gun% .
If i drop the double quote, it is found. with the double quote it is not.
In description or a separate keyword file probably won't make a difference?

It wouldn't be such a problem, but thousands of products in tools and automotive are designated by size.
I imagine hardware, clothing, as well as many other types of products are similar.
I just want people to be able to find things easily on sites I build. If you can't find it, you won't buy it.

Brent
I just had a moment to check the code for Request in version 7.9
I think the problem will be fixed with HTMLSPECIALCHARS encoding that is now included in the core.
Thanks for your help, Bruce
Last edited by Anonymous on Mon Nov 03, 2008 11:56 pm, edited 1 time in total.

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by bthirsk » Tue Nov 04, 2008 2:19 pm

The wildcard search now works. Quotes are fine in search string.
The problem was the $session->get('search.search')
There were multiple calls the return the search string in the SQL.
This function contains HTMLSPECIALCHARS and each time it was called, it
added another amp to the string. I Created a variable so I could call only once
and used the variable in SQL.

Version 7.9 would have worked out of the box because it does not do the HTMLSPECIALCHARS here.
Brent

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada

Post by Qphoria » Tue Nov 04, 2008 11:11 pm

So then this is already fixed in 0.7.9 now and no longer an issue?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by bthirsk » Tue Nov 04, 2008 11:29 pm

That is correct. 7.9 does not convert to HTML in session get anymore.
That allows you to do it once yourself and not destroy the input string.
Brent

Brent


Active Member

Posts

Joined
Wed Sep 03, 2008 11:33 am
Location - Canada
Who is online

Users browsing this forum: No registered users and 37 guests