![]() |
SKU Search: Want to go to Detail Product Page |
Post Reply ![]() |
Page 12> |
Author | |||
avalight ![]() Newbie ![]() Joined: 21-September-2007 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() Posted: 29-January-2011 at 12:52am |
||
Hi
Using information in another post, I have put this small search box code on my pages so that a SKU search can be performed. It works fine, except that the search results is the generic search results page, and I want it to go directly to the detailed product page. Is that possible? And if so, how or what do I change in the code to make it work. Thanks
Edited by avalight - 29-January-2011 at 12:56am |
|||
![]() |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Hey avalight,
Paste this code into showsearchresults.asp around line 147, just before this section:
Paste this code:
Then, edit your search form to include this hidden field:
*edit* The cool thing about this is that if they put a partial SKU in, it will still show the regular results page. For example if I have a product with SKU P112 and they search P11, it will show the results page, however P112 will direct them straight to the SEO link. Edited by Brett - 29-January-2011 at 8:52am |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Is this a safe way to use this query string? Will converting it to an integer address any sql injection issues?
|
|||
![]() |
|||
Greg Dinger ![]() Certified ProductCart Developers ![]() ![]() Joined: 23-September-2006 Location: United States Status: Offline Points: 238 |
![]() ![]() ![]() ![]() ![]() |
||
go look at the getuserinput command in stringfunctions.asp
|
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
I knew about getuserinput. It's all over showsearchresults.asp. However, I believe it causes a tech error if there is no variable (for example, a checkbox that isn't checked doesn't send anything to the query string). Therefore, an if statement! I'm pretty sure this is unnecessary, but here's an updated version of the code block to put into showsearchresults.asp.
|
|||
![]() |
|||
avalight ![]() Newbie ![]() Joined: 21-September-2007 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
||
Hi Brett
Before putting in this code, does it affect the behaviour of how any other searches work? Specifically, the custom search field search? From looking at this, it looks pretty specific to the SKU Search Box, but I wanted to make sure. Thanks curt |
|||
![]() |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
hey, this shouldn't do anything unless the skuJump query variable has been defined. it won't be defined unless it is included on the form. I haven't tested it against the custom field search, but it doesn't interfere with the rest of the search functions.
it just checks to see if skuJump is not zero, and if true then it redirects straight from the category search. i just tested it on my advanced search and everything appears to be working normally. i enabled it on our site because i thought it was a cool idea. you can see it here: http://www.liftchair.com/search.asp You'll notice that if it isn't checked, everything works as normal. However, if it is checked, it has a couple different behaviors: if you enter a complete sku, AND the checkbox is checked it jumps to that product's page (try P112) if you enter a partial sku, it shows the search results like normal. if it doesn't match a complete sku, it just continues running the search as usual. (try P11) if the checkbox is NOT checked, the sku box behaves how it originally did. |
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Here's my showsearchresults.asp file. I don't know if it's been modified besides this change, so make sure you back up your old file first. showsearchresults.zip
Like I said earlier, it won't work unless you make a form field called skuJump. I used a checkbox, but your original example called for a hidden field. This is probably what you want your "SKU Search" form to look like:
Here's the checkbox I added to my search.asp:
|
|||
![]() |
|||
Brett ![]() Groupie ![]() ![]() Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
![]() ![]() ![]() ![]() ![]() |
||
Hey Avalight, I made a couple updates to the showsearchresults.asp file. I simplified the first if statement and added another statement allowing me to use my regular search box for SKU jump, rather than needing a specific SKU search box: That way, people can use the search box as normal, but if they type a SKU in then it jumps to that page. Thought you might be interested.
|
|||
![]() |
|||
avalight ![]() Newbie ![]() Joined: 21-September-2007 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
||
Okay thanks. But the code in your Jan 29th post will work too, right? I want to just leave it as a sku search only.
|
|||
![]() |
|||
![]() |
Post Reply ![]() |
Page 12> |
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |