ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Customizing ProductCart
  New Posts New Posts RSS Feed - SKU Search: Want to go to Detail Product Page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SKU Search: Want to go to Detail Product Page

 Post Reply Post Reply Page  12>
Author
Message
avalight View Drop Down
Newbie
Newbie


Joined: 21-September-2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote avalight Quote  Post ReplyReply Direct Link To This Post Topic: SKU Search: Want to go to Detail Product Page
    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

<div id="pcStoreSearch" >
<!-- Start Search Box -->
<form action="/productcart/pc/showsearchresults.asp" name="search" method="get" class="pcForms">
<input type="hidden" name="pageStyle" value="<%=bType%>">
<SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; COLOR: rgb(0,161,0);">PRODUCT SEARCH:</span>
<input type="hidden" name="resultCnt" value="10">
<input type="Text" name="SKU" size="14" value="Enter Product No." onclick="this.value=''">
<b><input type="image" name="submit" src="/productcart/PC/images/btn_go_gray.gif" id="submit"></b>
</form>
<!-- End Search Box -->
</div>



Edited by avalight - 29-January-2011 at 12:56am
Curt
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 8:46am
Hey avalight,

Paste this code into showsearchresults.asp around line 147, just before this section:

'//===========================
'// BRAND Information - Start
'//===========================


Paste this code:

'//===========================
'// SKU Jump - Start
'//===========================
intSkuJump=cint(request.querystring("skuJump"))
if intSkuJump<>0 then
     query="SELECT idProduct, description FROM products WHERE sku='" & pSearchSKU & "';"
     set rstemp=Server.CreateObject("ADODB.Recordset")
     set rstemp=conntemp.execute(query)
     if not rstemp.eof then
          pIdProduct=rstemp("idProduct")
          pDescription=rstemp("description")
          %><!--#include file="pcSeoFirstCat.asp"--><%
              Â pcGenerateSeoLinks
          response.redirect pcStrPrdLink
     end if
     set rstemp=nothing
end if
'//===========================
'// SKU Jump - End
'//===========================



Then, edit your search form to include this hidden field:

<input type="hidden" name="skuJump" value="1">


*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
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 8:51am
Is this a safe way to use this query string? Will converting it to an integer address any sql injection issues?

intSkuJump=cint(request.querystring("skuJump"))
Back to Top
Greg Dinger View Drop Down
Certified ProductCart Developers
Certified ProductCart Developers
Avatar

Joined: 23-September-2006
Location: United States
Status: Offline
Points: 238
Post Options Post Options   Thanks (0) Thanks(0)   Quote Greg Dinger Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 10:25am
go look at the getuserinput command in stringfunctions.asp
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 10:40am
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.


'//===========================
'// SKU Jump - Start
'//===========================
if request.querystring("skuJump") <> "" then
     intSkuJump=cint(getUserInput(request.querystring("skuJump"),0))
else
     intSkuJump=0
end if
if intSkuJump<>0 then
     query="SELECT idProduct, description FROM products WHERE sku='" & pSearchSKU & "';"
     set rstemp=Server.CreateObject("ADODB.Recordset")
     set rstemp=conntemp.execute(query)
     if not rstemp.eof then
          pIdProduct=rstemp("idProduct")
          pDescription=rstemp("description")
          %><!--#include file="pcSeoFirstCat.asp"--><%
               pcGenerateSeoLinks
          response.redirect pcStrPrdLink
     end if
     set rstemp=nothing
end if
'//===========================
'// SKU Jump - End
'//===========================
Back to Top
avalight View Drop Down
Newbie
Newbie


Joined: 21-September-2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote avalight Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 3:14pm
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

Curt
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 5:32pm
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.
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 29-January-2011 at 5:36pm
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:

<div id="pcStoreSearch" >
<!-- Start Search Box -->
<form action="/productcart/pc/showsearchresults.asp" name="search" method="get" class="pcForms">
<input type="hidden" name="pageStyle" value="<%=bType%>">
<SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 11pt; COLOR: rgb(0,161,0);">PRODUCT SEARCH:</span>
<input type="hidden" name="resultCnt" value="10">
<input type="hidden" name="skuJump" value="1">
<input type="Text" name="SKU" size="14" value="Enter Product No." onclick="this.value=''">
<b><input type="image" name="submit" src="/productcart/PC/images/btn_go_gray.gif" id="submit"></b>
</form>
<!-- End Search Box --></div>


Here's the checkbox I added to my search.asp:

<input name="skuJump" type="checkbox" value="1">
Back to Top
Brett View Drop Down
Groupie
Groupie
Avatar

Joined: 22-April-2008
Location: Phoenix, AZ
Status: Offline
Points: 89
Post Options Post Options   Thanks (0) Thanks(0)   Quote Brett Quote  Post ReplyReply Direct Link To This Post Posted: 03-February-2011 at 3:17pm
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.


'//===========================
'// SKU Jump - Start
'//===========================
intSkuJump=0
if request.querystring("skuJump") <> "" then
     intSkuJump=cint(getUserInput(request.querystring("skuJump"),0))
end if
if intSkuJump<>0 then
     skuSearchTerm = ""
     if pSearchSKU <> "" then
          skuSearchTerm = pSearchSKU
     else
          skuSearchTerm = pKeywords
     end if
     query="SELECT idProduct, description FROM products WHERE sku='" & skuSearchTerm & "';"
     set rstemp=Server.CreateObject("ADODB.Recordset")
     set rstemp=conntemp.execute(query)
     if not rstemp.eof then
          pIdProduct=rstemp("idProduct")
          pDescription=rstemp("description")
          %><!--#include file="pcSeoFirstCat.asp"--><%
               pcGenerateSeoLinks
          response.redirect pcStrPrdLink
     end if
     set rstemp=nothing
end if
'//===========================
'// SKU Jump - End
'//===========================
Back to Top
avalight View Drop Down
Newbie
Newbie


Joined: 21-September-2007
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote avalight Quote  Post ReplyReply Direct Link To This Post Posted: 03-February-2011 at 3:24pm
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.
Curt
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.078 seconds.