ADDING SKU'S TO STOREFRONT


 

You may want to use PAM (product attribute

manager) from  http://www.sfinsider.com.

or (in my case) you're comfortable with ASP and you can quickly and easily

knock it out.

 

For the ASP geeks:

1. The easiest way is to only use Attributes A and B and use Attribute C

to store the SKU number. This way Bob's code takes you through to the check-out

form all the way to the confirmation email and even the reports. This is

the best because you're changing less of his code and trust me that is the

better way of doing things because then updates from StoreFront will still

work (mostly).

 

2. Ok so now you realize that all I need to do is show the customer the page,

let them chose a product (the color and size) and then figure out what sku

number that would be and then write that SKU number to attribute C and THAT'S

IT!

 

3. Ok how do we do that? JavaScript.

A. on my "detail.asp" page I have a ASP ".inc" "include" file:

 

<SCRIPT Language="JavaScript">

<!--

function getattributes(form2)

{

var si = (form2.AttributeA.selectedIndex);

var selone = (form2.AttributeA.options[si].value)

var si = (form2.AttributeB.selectedIndex);

var seltwo = (form2.AttributeB.options[si].value)

var findsku = selone + seltwo

 

<%

SQL="SELECT * FROM attribuites WHERE StyleID= '" & PRODUCT_ID & "'"

Set RS = Connection.Execute(SQL)

%>

  

  <%

        If Not RS.EOF Then

        RS.MoveFirst %>

 

<% Do While NOT RS.EOF %>

 

<% Thissku= "" & RS("SizeSpec") & RS("Description") & "" %>

 

 if(findsku=="<%=Thissku %>")

   {

        (form2.AttributeC.value="<%=RS("SKU")%>")

        return(true);    

        }       

<% RS.MoveNext %>

<% Loop %>

<% End if %>

        {

        alert("Sorry, That Selection is not in stock.")

        return(false);

   }

 

}

<!-- done hiding -->

</SCRIPT>

 

************** That produces this :

 

<SCRIPT Language="JavaScript">

<!--

function getattributes(form2)

{

var si = (form2.AttributeA.selectedIndex);

var selone = (form2.AttributeA.options[si].value)

var si = (form2.AttributeB.selectedIndex);

var seltwo = (form2.AttributeB.options[si].value)

var findsku = selone + seltwo

 

if(findsku=="9Pink")

   {

        (form2.AttributeC.value="114342101063")

        return(true);     

        }       

 

 

 if(findsku=="11Pink")

   {

        (form2.AttributeC.value="114342101070")

        return(true);    

        }       

 

        {

        alert("Sorry, That Selection is not in stock.")

        return(false);

   }

 

}

<!-- done hiding -->

</SCRIPT>

 

4. Ok what's happing here is:

 

I created one new table and added it to the StoreFront database. This table

has 5 fields:

 

*skuid

(counter)

 

*SKU

 (this is the value that I will eventually put in Attribute C)

 

*ColorID

 (this is written to the Detail.asp page so they can first choose it then

it and the SizeID value are "connected" to create one vale (for example "SGreen"

is "small" and "green"))

 

*SizeID

(this is written to the Detail.asp page so they can first choose it then

it and the ColorID value are "connected" to create one vale (for example

"MWhite" is "medium" and "white"))

 

* StyleID

 (this is the same number that is entered into the normal StoreFront Product

table to identify the product (basically what I am doing here is saying"

hey what product did someone want? ok now look at the "attributes" table

and find each entry in that table that has a "StyleID" that matches the "PRODUCT_ID"

that the person chose)

 

4.1. I use the above ASP code to read through my table I added called "Attributes"

(<% SQL="SELECT * FROM attribuites WHERE StyleID= '" & PRODUCT_ID & "'" Set

RS = Connection.Execute(SQL) %>), I write the JavaScript part (see the example

above of the code and what a sample of the output looks like (this code is

placed at the top of the eventual output of the "detail.asp" page) and the

rest of the body of the "detail.asp" page.

 

4.2. When someone selects a possible choice for Attribute A it is stored

as the "selone" variable, for Attribute B it is stored as the  "seltwo" variable.

Then I create a "findsku" variable that is "selone + seltwo" (findsku = selone

+ seltwo) and I then compare that to the possibilities that I wrote in the

JavaScript. If nothing matches it says "sorry out of stock" (because you

MAY have small and you may have green, but you may not have small and white.

The person can make that selection because the size box has small is available

and color box has white available)

 

4.3 If a match is found, the JavaScript line (for example "(form2.AttributeC.value="114342101063")"

) puts "114342101063" as the value for attribute C and then sends the user

along just as they would be if they had hit the "BUY NOW" button. Also note,

the JavaScript does not run until the person hits the "BUY NOW" button because

it has a line like this: "<%=Session("sfPath") %>" method="POST" name="form2"

onsubmit="return getattributes(this)" rather than the normal StoreFront code:

"form action="<%=Session("sfPath") %>" method="POST" id=form2 name=form2"

 

5. That's it (mostly). If I want to know what the SKU number was I simply

look for Attribute C (when customizing my checkout page I simply say: "the

SKU number is <% RSOrder("AttributeC") %>")

 

**** IN SUMMERY

1. All I did was add one table that listed my SKU

2. The hard part (but easy for you because I give you the code) is the JavaScript

that ties it together

3. The only page this really affects is the detail page and even there I

am using all the same variable names so as not to screw up StoreFront

4. The point I am trying to make is that you can ADD the functionality to

handle SKU WITHOUT causing MAJOR changes to StoreFront that you might regret

later because other stuff gets screwed up (for example reports - the sku

simple shows up in the Attribute C column, I don't have to rewrite the code

that generates the reports).