VP-ASP :: Shopping Cart Software

Shopping Cart Software Solutions for anywhere in the World

US/Canada(Toll Free): +1 888 587 2278
Europe/UK: +44 (020) 7193 9408
Australia/New Zealand: +61 3 9016 4497

VP-ASP Shopping Cart Customer Forum

Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VPCart Forum
 Customization
 Enhance search utility to act more like Google
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

MiniMe
Starting Member

24 Posts

Posted - December 15 2003 :  00:25:32  Show Profile  Reply with Quote
Hi,

I wanted the search utility that came with VPASP 5.0 have several features:
- to enable users to search without the user having to separate search words with commas.
- users to be able to search phrases by surrounding words with quotation marks, like you can in Google and other search engines.
- Finally, I wanted search terms entered to be searched on as "all words" rather then "any word" because I find people try narrowing down results by adding more words. For example, if a user enters the terms 'mp3 case' I would rather return results that contain both words rather then either because clearly they're looking for an case for their mp3 player.

I seem to have been able to accomplish this with a bit of code. It works on my system and feel free to use it but of course there's I can't guarantee that it will work for you.
Also, I'm by no means a professional programmer so if you see errors in it please let me know by posting. Feel free to try the search at minidisc-canada.com if you're curious.

To accomplish this REPLACE line 258 in "shopsearch.asp" from strKeyword = Request("Keyword") with:

' start modifications
strKeyword = Trim(Request("Keyword"))
if strKeyword<>"" then
Dim FindString, Position, KeyWordArray, NumTerms, SearchPortion, StringLength
FindString = """"
Position = InStr(strKeyword, FindString)
strKeyword = Replace(strKeyword,"""",""",")
If Position <> "1" Then
KeyWordArray = Split(strKeyword, """", -1, 1)
For NumTerms = 0 To Ubound(KeyWordArray) Step 2
SearchPortion = Replace(KeyWordArray(NumTerms)," ",",")
KeyWordArray(NumTerms) = SearchPortion
Next
End If

If Position = "1" Then
KeyWordArray = Split(strKeyword, """", -1, 1)
For NumTerms = 0 To Ubound(KeyWordArray) Step 2
SearchPortion = Replace(Trim(KeyWordArray(NumTerms))," ",",")
KeyWordArray(NumTerms) = SearchPortion
Next
End If
strKeyword = Join(KeyWordArray)
strKeyword = Replace(strKeyword,", ",",")
strKeyword = Replace(strKeyword," ,",",")
strKeyword = Replace(strKeyword,",,",",")
'this code cuts off the leading comma that gets put there if the first character in the search is a quotation mark.
If Position = "1" Then
StringLength = Len(strKeyword)
StringLength = StringLength-1
strKeyword = Right(strKeyword, StringLength)
End If
'end of modifications

The above code replaces spaces between search tems with commas for you, except for the terms that are surrounded by quotation marks where it leaves the spaces so it can search those terms as a phrase.

If you want the search to display results based with all search terms rather then any search term open the file called "shopproductcreatesql.asp", navigate to line 108 and REPLACE:
whereok=" OR "
with:
whereok=" AND "

There you have it.

Hope this comes in handy. If you use it and find you have any enhancements to offer please share! Thanks.


Edited by - MiniMe on December 15 2003 05:13:19

Habitue
VP-ASP New User

USA
90 Posts

Posted - December 16 2003 :  01:35:48  Show Profile  Reply with Quote
Pretty cool. Many thanks for sharing!

Peace,

~Habitue~

----------------------------------
"I've heard that it's good to think before you speak..." - TBC
Go to Top of Page

Jill
VP-ASP Super User

USA
249 Posts

Posted - December 28 2003 :  23:54:16  Show Profile  Reply with Quote
This looks really neat, but I'm getting this error:

Microsoft VBScript compilation error '800a03f4'

Expected 'If'

/shopsearch.asp, line 322

end sub
----^


I commented out this line: strKeyword = Request("Keyword"), and added in MiniMe's code after it. Any idea what is wrong?

Jill

Go to Top of Page

MiniMe
Starting Member

24 Posts

Posted - December 29 2003 :  23:54:07  Show Profile  Reply with Quote
Hi Jill,

I don't get any error so I'm not sure what's going on.

I'd like to help but I have a couple of questions for you:
- are you certain that you copied and pasted the code exactly without removing anything except the line 258 in "shopsearch.asp" [strKeyword = Request("Keyword")]?

- After inserting my modified code, my line 322 in shopsearch.asp reads "objrs.open "searchresults", dbc, adopenkeyset, adlockoptimistic, adcmdtable". I don't have an "end sub" near it. So I'm not sure where in the page your line 322 is. Could you be more specific? Maybe tell what a few lines before and after your line 322 read.

- Make sure you keep the original code following the modifications as they are. Therefore the lines after the modifications should be:
Delimiter=","
parseRecord strKeyword, words, wordcount,delimiter
CorrectSearchWords words, wordcount
Else
wordcount=0
end if
end sub
...

If you keep the above code the "end if" statement should close it up and there should be no error. Could you double check this?

- I have VPASP 5.0 and haven't tested it on other versions, so obviously it might not work on previous versions.

Hope this helps. If you still have problems, please post. If it works out, also please post because I'm curious to know if this works for others as well :)

Regards.

Edited by - MiniMe on January 07 2004 22:54:04
Go to Top of Page

jonmadrid
VP-ASP New User

USA
192 Posts

Posted - January 08 2004 :  13:14:07  Show Profile  Visit jonmadrid's Homepage  Reply with Quote
MiniMe, Jill:

Thanks for the contribution; looks like it would be handy. I tried the code that you posted in your original post and got the same error Jill did. It was due to an unclosed 'If' statement, towards the top.

Your original code is below, with *** *** around the original 'If' and 'End If' statements. Notice that there are two instances of 'If' and only one 'End If':

********
strKeyword = Trim(Request("Keyword"))
***if*** strKeyword<>"" then
Dim FindString, Position, KeyWordArray, NumTerms, SearchPortion, StringLength
FindString = """"
Position = InStr(strKeyword, FindString)
strKeyword = Replace(strKeyword,"""",""",")
***If*** Position <> "1" Then
KeyWordArray = Split(strKeyword, """", -1, 1)
For NumTerms = 0 To Ubound(KeyWordArray) Step 2
SearchPortion = Replace(KeyWordArray(NumTerms)," ",",")
KeyWordArray(NumTerms) = SearchPortion
Next
***End If***
End If 'This final End If needs to be added in.
********

Because that 'If' statement hadn't been closed with an 'End If', it threw the error when the 'end sub' line came around. I've tried it and it seems to work now. Jill, does that solve your problem?

All the best,

Jon Madrid
--------------------
Madrid Communications
Web Design, Development, and Hosting
www.madridcom.com
Go to Top of Page

Jill
VP-ASP Super User

USA
249 Posts

Posted - January 08 2004 :  18:10:47  Show Profile  Reply with Quote
That seems to have done it! Thanks, both of you.

Jill



Go to Top of Page

Justin
VP-ASP New User

87 Posts

Posted - October 19 2004 :  07:03:13  Show Profile  Visit Justin's Homepage  Reply with Quote
Just a note for v4.5 users:

The "OR" line you want to change in shopproductcreatesql.asp is not on 108, but on 95.

I'm not sure if this applies only to 4.5 or to everyone else, but the End If that John suggested above actually works better if you put it right at the end of MiniMe's original code. It's the one that pairs with "if strKeyword <> ""then". The reason being that if the keyword field is blank then you don't want to touch the string - you want to leave it as blank. This matters if you want to do a blank search (ie bring up all products). Otherwise it throws an error.

JL



Go to Top of Page

keng
VP-ASP New User

152 Posts

Posted - October 20 2004 :  00:24:23  Show Profile  Reply with Quote
Thanks for all your contribution! This works very well with mine except:

In version 5.5 there is an option to search High and Low Price. If I type in the "Low Price" box ex. 5.00, I get this error message:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Join'

shopsearch.asp, line 294

Please help!


Go to Top of Page

keng
VP-ASP New User

152 Posts

Posted - October 20 2004 :  17:52:46  Show Profile  Reply with Quote
Bump! Still need help.

Go to Top of Page

Justin
VP-ASP New User

87 Posts

Posted - October 21 2004 :  20:49:27  Show Profile  Visit Justin's Homepage  Reply with Quote
Actually, just wondering if anyone has tried this hack in conjunction with the "prodcategories" table? That is, having a shop where a product can appear in more than one category. I'm not sure whether it is due to this hack, or just the way the search code works, but I've noticed an issue when you click a category checkbox and then also select a subcategory. Basically, you can never get any results. The reason being the following session variable:

Session Object SQL = select DISTINCTROW p.catalogid, p.ccode, p.cname, p.cdescription, p.cprice, p.ccategory, p.cdescurl, p.features, p.cimageurl, p.cstock, p.weight, p.mfg, p.pother1, p.pother2, p.pother3, p.subcategoryid, p.retailprice, p.specialoffer, p.category, p.buttonimage, p.cdateavailable, p.allowusertext, p.pother4, p.pother5, p.userid, p.keywords, p.template, p.extendedimage, p.extendeddesc, p.selectlist, p.level3, p.level4, p.level5, p.minimumquantity, p.supplierid, p.crossselling, p.hide, p.productmatch, p.customermatch, p.orderattachment, p.orderdownload, p.groupfordiscount, p.clanguage from products p, prodcategories cc, categories c where cc.intcatalogid=p.catalogid and cc.intcategoryid=c.categoryid AND ( cc.intCategoryId = 23) AND (cc.intcategoryid=24) AND hide=0 order by specialoffer desc,cname

Obviously there is no way intcategory could be 23 AND 24. I was wondering if this was because of the 2nd part of MiniMe's hack, or whether it is actual VPASP functionality.

Justin


Go to Top of Page

keng
VP-ASP New User

152 Posts

Posted - December 14 2004 :  14:54:11  Show Profile  Reply with Quote
Would you recommend this tool? I am considering it but I wonder if this is effective?

Go to Top of Page

wft
VP-ASP New User

66 Posts

Posted - December 19 2004 :  23:17:29  Show Profile  Visit wft's Homepage  Reply with Quote

I got similar type mismath error, once there is an empty string search. another word, when a search text box is emplty and the search is performed.


i need to check add an if statement to check strkeyword <> "" then the Join functin won't get error. since the join functin require the list(array) to pass.



vpasp templates

Go to Top of Page

directd
Starting Member

14 Posts

Posted - April 13 2005 :  08:15:04  Show Profile  Reply with Quote
This code works well for us. However does anyone know how to remove the hidden products from the search?

Thanks
KAS

Go to Top of Page

apswater
VP-ASP Super User

317 Posts

Posted - April 13 2005 :  09:31:46  Show Profile  Visit apswater's Homepage  Reply with Quote
I use this search.

http://www.wrensoft.com/zoom/

It not only picks off only the products listed (solved the hidden product problem) it also will pick up all the categopries and subcateories as well as any text you have on your site. You can try it here http://www.drinkingwaterdepot.com

It is excellent.




Edited by - apswater on April 13 2005 09:32:32
Go to Top of Page

Cam
VP-ASP Super User

Australia
361 Posts

Posted - April 15 2005 :  18:26:18  Show Profile  Visit Cam's Homepage  Reply with Quote
That is a nice search tool. I just set up the demo in about 1 minute and indexed my site and displayed the results of all pages including dynamic ones.

Thanks for posting.

Cam
VPASP Support

*************************************
Cam Flanigan
YourVirtualStore Sales
e-mail:
http://www.vpasp.com/sales/shopcustcontact.asp
web: http://www.yourvirtualstore.net

Build you own YourVirtualStore!!!
www.yourvirtualstore.net
*************************************
Go to Top of Page

rvaga
VP-ASP Super User

USA
254 Posts

Posted - April 20 2005 :  15:30:38  Show Profile  Reply with Quote
Another one to consider is mondosoft.com but it's considerably more expensive. Search results are listed, then when you click on the most suitable page, the keywords are highlighted. Add VPASP shopping cart stuff, and it's pretty slick - very much unlike the typical web site where a database search result can be overwhelming.

To see how the mondosoft search works with VPASP, visit my site (click the large word "Search" right above the piano bench):
http://www.sheetmusic1.com

Please buy $400 worth of music, so I can pay off my shopping cart investment (grin! - just kidding)

Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000