BenEskew.com Just another web developer's personal weblog.

7Aug/100

Display MSRP in product.SimpleProduct.xml XMLPackage in AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

By default in AspDotNetStorefront the MSRP for products is not displayed or used within the product.SimpleProduct.xml XMLPackage, so if you would like to use or display it you will need to make some fine-tuned adjustments.

The Quick and Dirty Way (not as efficient):

In your product.SimpleProduct.xml XMLPackage find the lines where database queries are being made, like:

...
<query name="Products" rowElementName="Product" runif="edit">
<sql>
<![CDATA[
exec dbo.aspdnsf_EditOrderProduct @ShoppingCartRecID, @CustomerLevelID
]]>
</sql>
<queryparam paramname="@ShoppingCartRecID" paramtype="request" requestparamname="CartRecID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
<queryparam paramname="@CustomerLevelID" paramtype="system" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
</query>
...

and add a new database query by adding the following after the last query:

<query name="Variant" rowElementName="Price" runif="showproduct">
<sql>
<![CDATA[
select MSRP from dbo.ProductVariant with(NOLOCK) where ProductID=@ProductID and IsDefault=1
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</query>

ex.

...
<query name="Products" rowElementName="Product" runif="edit">
<sql>
<![CDATA[
exec dbo.aspdnsf_EditOrderProduct @ShoppingCartRecID, @CustomerLevelID
]]>
</sql>
<queryparam paramname="@ShoppingCartRecID" paramtype="request" requestparamname="CartRecID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
<queryparam paramname="@CustomerLevelID" paramtype="system" requestparamname="CustomerLevelID" sqlDataType="int" defvalue="0" validationpattern="" />
</query>
<query name="Variant" rowElementName="Price" runif="showproduct">
<sql>
<![CDATA[
select MSRP from dbo.ProductVariant with(NOLOCK) where ProductID=@ProductID and IsDefault=1
]]>
</sql>
<queryparam paramname="@ProductID" paramtype="request" requestparamname="ProductID" sqlDataType="int" defvalue="0" validationpattern="^\d{1,10}$" />
</query>

...

Now, in your XMLPackage wherever you'd like to display the MSRP, simply add the following:

<xsl:value-of select="aspdnsf:FormatCurrency(/root/Variant/Price/MSRP)" disable-output-escaping="yes" />

The Efficient Way (MS SQL):

Using SQL Management Studio, open up the stored procedure and locate near the bottom where it reads:

...
SELECT
p.*,
pv.VariantID, pv.name VariantName, pv.Price, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, pv.Inventory, pv.ImageFilenameOverride VariantImageFilenameOverride, pv.isdefault, pv.CustomerEntersPrice, isnull(pv.colors, '') Colors, isnull(pv.sizes, '') Sizes,
...

simply add the MSRP table call to the select statement, like:

...
SELECT
p.*,
pv.VariantID, pv.name VariantName, pv.Price, pv.MSRP, pv.Description VariantDescription, isnull(pv.SalePrice, 0) SalePrice, isnull(SkuSuffix, '') SkuSuffix, pv.Dimensions, pv.Weight, isnull(pv.Points, 0) Points, pv.Inventory, pv.ImageFilenameOverride VariantImageFilenameOverride, pv.isdefault, pv.CustomerEntersPrice, isnull(pv.colors, '') Colors, isnull(pv.sizes, '') Sizes,
...

Now, execute the statement.
Finally, in your XMLPackage where you'd like to display the MSRP simply add the following:

<xsl:value-of select="aspdnsf:FormatCurrency(MSRP)" disable-output-escaping="yes" />

Or, if you're calling it from outside of the Product template, use the full xpath, like:

<xsl:value-of select="aspdnsf:FormatCurrency(/root/Products/Product/MSRP)" disable-output-escaping="yes" />

7Aug/100

Display SKU in product.SimpleProduct.xml XMLPackage in AspDotNetStorefront

ASPDNSF Version: 9 (C# + MS SQL)

By default in AspDotNetStorefront the SKU for products is not displayed or used within the product.SimpleProduct.xml XMLPackage, so if you would like to use or display it you will need to make some fine-tuned adjustments.

First:
In your product.SimpleProduct.xml XMLPackage find the lines where the Product is being handled, namely the lines starting with:

...
<xsl:template match="Product">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>

...
...

and add a new parameter call to the parameters by adding:

<xsl:param name="pSKU" select="aspdnsf:GetMLValue(SKU)"></xsl:param>

ex.

...
<xsl:template match="Product">
<xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
<xsl:param name="pDescription" select="aspdnsf:GetMLValue(Description)"></xsl:param>
<xsl:param name="pSalesPromptName" select="aspdnsf:GetMLValue(SalesPromptName)"></xsl:param>
<xsl:param name="pSKU" select="aspdnsf:GetMLValue(SKU)"></xsl:param>

...
...

Now, in your XMLPackage wherever you'd like to display the SKU, simply add the following:

<xsl:value-of select="$pSKU" disable-output-escaping="yes"/>

Using this method you can call any field from the Product table including Variants, like if you simply wanted to get the ProductID so you can display it in the XMLPackage...

...set parameter for it:
<xsl:param name="pID" select="aspdnsf:GetMLValue(ProductID)"></xsl:param>

...use it:
...href="http://www.yoursite.com/EMailproduct.aspx?productid={$pID}"><img src="http://www.yoursite.com/App_Themes/Skin_1/images/Icon-Email.gif"...