Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 9 of 9

Thread: Custom Recently Viewed Products XML Package

  1. #1
    cfwebmasters is offline Junior Member
    Join Date
    Mar 2007
    Posts
    26

    Angry Custom Recently Viewed Products XML Package

    In the lastest copy of version 9 (c#) - I want to create a custom XML package that loads from the Skin_1/XMLPackages/ directory (i.e. /Skin_1/XMLPackages/rev.recentlyviewed.xml.config) that shows the list of recently viewed products, up to the number from the appconfigs, AND shows on EVERY page.

    Now, I've copied the default recentlyviewed.xml.config XMLPackage from the root XMLPackages folder into my /Skin_1/XMLPackages folder.

    I've added the literal to call the package:
    Code:
    <asp:Literal ID="SiteRecentlyViewed" runat="server" Text='<%$Tokens:XMLPACKAGE, rev.recentproducts.xml.config %>'></asp:Literal>
    And I've confirmed the package is loading by setting it to "Debug" mode. But, for some reason unbeknownst to me, the <RecentlyProducts /> node is always empty in my custom package, even though I can copy and paste THE EXACT SAME CODE into the root XMLPackages recentlyviewed.xml.config XMLPackage, and have results show at the bottom of my template pages.

    No matter what I do, no Recently Viewed products will show on the home page...period.

    I must admit this is EXTREMELY frustrating. I don't want the Recently viewed products to show at the bottom of the page in the goofy "box" frame. I want them to appear in my right-hand rail, where the design requires them, AND, I need to be able to pull them from a package in the Skin_1 folder, so the next "upgrade" doesn't wipe out the xml package.

    Can anyone lend a hand here? What gives?

  2. #2
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Hi

    This is a guess but it sounds like your XmlPackage isn't able to retrieve the runtime ProductID parameter that should be passed to it.

    The stored procedure called by the RecentlyViewed XML package does a query for all recently viewed products that aren't the @productid param.

    If you call the procedure without this, it complains and returns nothing - which sounds similar to your problem.

    As a test, try hard-coding a valid product ID into your XML Package's SQL statement, and also, in debug mode look for a runtime 'productid' which is the one it should really be using.

  3. #3
    ssgumby is offline Senior Member
    Join Date
    Feb 2009
    Posts
    683

    Default

    I believe webopius hit the nail on the head, and in 9.x runtime parameters are not passed to the XmlPackages.

  4. #4
    cfwebmasters is offline Junior Member
    Join Date
    Mar 2007
    Posts
    26

    Default

    Okay...
    That makes sense. That would also imply that the recentlyviewed.xml.config XML Package is relying on the "ProductID" parametery being supplied dynamically by the codebase, rather than via XML Runtime parameters...since the using an exact copy of their package does nothing, yet theirs continues to appear at the bottom of my "Template" pages.

    I'm going to give the recommendation a reply and see where I get. I'll post back when I have some results.

  5. #5
    cfwebmasters is offline Junior Member
    Join Date
    Mar 2007
    Posts
    26

    Default No <productid /> in Runtime results

    Okay...So, I'm going to post the XML Package code, and the Debug output below. If you don't mind, take a peek and see if you spot anything obvious. There is no <productid /> parameter in the debug output, and in the SQL statement, the default value for the parameter "productid" is 0. I tried hardcoding the defvalue to a valid product id (4), and got nothing.

    First, the XML Package rev.recentlyviewed.xml.config
    Code:
    <?xml version="1.0" standalone="yes" ?>
    <package version="2.1" displayname="Recently Viewed Products" debug="true" includeentityhelper="false">
    
      <!-- ###################################################################################################### -->
      <!-- Copyright AspDotNetStorefront.com, 1995-2010.  All Rights Reserved.					                -->
      <!-- http://www.aspdotnetstorefront.com														                -->
      <!-- For details on this license please visit  the product homepage at the URL above.		                -->
      <!-- THE ABOVE NOTICE MUST REMAIN INTACT.                                                                   -->
      <!--                                                                                                        -->
      <!-- ###################################################################################################### -->
    
    
      <query name="RecentlyViewedProducts" rowElementName="Item">
        <sql>
          <![CDATA[
    	        exec dbo.aspdnsf_GetRecentlyViewedProducts
    			    @productID,
    				  @customerGUID,
    				  @invFilter,
    				  @recentlyViewedProductsNumToDisplay,
    				  @storeID,
              @FilterProduct
          ]]>
        </sql>
        <queryparam paramname="@productid"								            paramtype="runtime"   requestparamname="productid"                                  sqlDataType="int"				defvalue="4"  validationpattern="" />
        <queryparam paramname="@customerGUID"							            paramtype="runtime"   requestparamname="custGuid"                                   sqlDataType="nvarchar"	defvalue=""   validationpattern="" />
        <queryparam paramname="@invFilter"								            paramtype="appconfig" requestparamname="HideProductsWithLessThanThisInventoryLevel" sqlDataType="int"				defvalue="0"  validationpattern="" />
        <queryparam paramname="@recentlyViewedProductsNumToDisplay"		paramtype="appconfig" requestparamname="RecentlyViewedProducts.NumberDisplayed"     sqlDataType="int"       defvalue="0"  validationpattern="" />
    	  <queryparam paramname="@StoreID"								              paramtype="runtime"   requestparamname="StoreID"									                  sqlDataType="int"				defvalue="1"  validationpattern="" />
        <queryparam paramname="@FilterProduct"                        paramtype="runtime"   requestparamname="FilterProduct"										           sqlDataType="bit"	    defvalue="0"  validationpattern="" />
      </query>
    
    
      <PackageTransform>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                            xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
          <xsl:output method="html" omit-xml-declaration="yes" />
    		
          <xsl:param name="RecentlyViewedProducts.NumberDisplayed" select="aspdnsf:AppConfig('RecentlyViewedProducts.NumberDisplayed')"></xsl:param>
          <xsl:param name="RecentlyViewedProductsGridColWidth" select="aspdnsf:AppConfig('RecentlyViewedProductsGridColWidth')"></xsl:param>
    
    
          <xsl:template match="/">
            <xsl:param name="encloseInTab" select="aspdnsf:EvalBool(/root/Runtime/EncloseInTab)" />
    		
            <xsl:choose>
    			<xsl:when test="count(/root/RecentlyViewedProducts/Item) &gt; 0">
    				<div id="it-recently-viewed">
    					<h3>Recently Viewed</h3>
    					<ul>
    
    
    						<xsl:choose>
    							<xsl:when test="aspdnsf:StrToLower(aspdnsf:AppConfig('RecentlyViewedProducts.ProductsFormat')) = 'grid'">
    								<xsl:apply-templates select="/root/RecentlyViewedProducts/Item" />
    							</xsl:when>
    						<xsl:otherwise>
    						<xsl:for-each select="/root/RecentlyViewedProducts/Item">
    							<xsl:variable name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:variable>
    							<xsl:variable name="pSEAltText" select="aspdnsf:GetMLValue(SEAltText)"></xsl:variable>
    							<xsl:variable name="AltText">
    								<xsl:choose>
    									<xsl:when test="$pSEAltText=''">
    										<xsl:value-of select="$pName" />
    									</xsl:when>
    									<xsl:otherwise>
    										<xsl:value-of select="$pSEAltText" />
    									</xsl:otherwise>
    								</xsl:choose>
    							</xsl:variable>
    							<li>
    								<xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'icon', 0, SEAltText)" disable-output-escaping="yes"/>
    								<a href="{aspdnsf:ProductLink(ProductID, SEName, 0, '')}">
    									<xsl:value-of select="aspdnsf:Ellipses(aspdnsf:GetMLValue(Name),48,true)" disable-output-escaping="yes" />
    								</a>
    							</li>
    							</xsl:for-each>
    						</xsl:otherwise>
    						</xsl:choose>
    
    					</ul>
    				</div>
    				<div class="it-hr"></div>
    
    			</xsl:when>
    			<xsl:otherwise>
    				<!--				
    					<xsl:value-of select="aspdnsf:StringResource('showproduct.aspx.42')" disable-output-escaping="yes" />
    				-->	
    			</xsl:otherwise>		
            </xsl:choose>
    		  
          </xsl:template>
    
          <xsl:template match="Item">
            <xsl:variable name="delta">
              <xsl:choose>
                <xsl:when test="(count(/root/RecentlyViewedProducts/Item) mod number($RecentlyViewedProductsGridColWidth)) = 0">0</xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="number($RecentlyViewedProductsGridColWidth)-(count(/root/RecentlyViewedProducts/Item) mod number($RecentlyViewedProductsGridColWidth))"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:variable>
            <xsl:variable name="rows" select="ceiling(count(/root/RecentlyViewedProducts/Item) div number($RecentlyViewedProductsGridColWidth))" />
    
            <xsl:if test="$RecentlyViewedProductsGridColWidth = 1">
              <tr>
                <xsl:call-template name="ProductCell"></xsl:call-template>
                <xsl:if test="ceiling(position() div  number($RecentlyViewedProductsGridColWidth)) = $rows and $delta &gt; 0">
                  <xsl:call-template name="FillerCells">
                    <xsl:with-param name="cellCount" select="$delta" />
                  </xsl:call-template>
                </xsl:if>
              </tr>
            </xsl:if>
    
            <xsl:if test="position() mod $RecentlyViewedProductsGridColWidth = 1 and $RecentlyViewedProductsGridColWidth &gt; 1">
              <tr>
                <xsl:for-each select=". | following-sibling::*[position() &lt; $RecentlyViewedProductsGridColWidth]">
                  <xsl:call-template name="ProductCell"></xsl:call-template>
                </xsl:for-each>
                <xsl:if test="ceiling(position() div  number($RecentlyViewedProductsGridColWidth)) = $rows and $delta &gt; 0">
                  <xsl:call-template name="FillerCells">
                    <xsl:with-param name="cellCount" select="$delta" />
                  </xsl:call-template>
                </xsl:if>
              </tr>
            </xsl:if>
    
          </xsl:template>
    
          <xsl:template name="ProductCell">
    
            <xsl:param name="pName" select="aspdnsf:GetMLValue(Name)"></xsl:param>
    
            <xsl:param name="AltText">
              <xsl:choose>
                <xsl:when test="aspdnsf:GetMLValue(SEAltText)=''">
                  <xsl:value-of select="aspdnsf:GetMLValue(Name)" />
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="aspdnsf:GetMLValue(SEAltText)" />
                </xsl:otherwise>
              </xsl:choose>
            </xsl:param>
    
            <td align="center" valign="top">
              <a href="{aspdnsf:ProductLink(ProductID, SEName, 0, '')}">
                <xsl:value-of select="aspdnsf:LookupProductImage(ProductID, ImageFilenameOverride, SKU, 'icon', 0, $AltText)" disable-output-escaping="yes"/>
              </a>
              <br/>
              <a href="{aspdnsf:ProductLink(ProductID, SEName, 0, '')}">
                <xsl:value-of select="$pName" disable-output-escaping="yes"/>
              </a>
              <xsl:if test="aspdnsf:AppConfigBool('DisplayOutOfStockProducts') = 'true'">
                <xsl:value-of select="aspdnsf:DisplayProductStockHint(ProductID,'Product')" disable-output-escaping="yes" />
              </xsl:if>
            </td>
          </xsl:template>
    
    
          <xsl:template name="FillerCells">
            <xsl:param name="cellCount"/>
            <xsl:param name="CellWidth" select="100 div $RecentlyViewedProductsGridColWidth" />
            <td width="{$CellWidth}%">&#160;</td>
            <xsl:if test="$cellCount > 1">
              <xsl:call-template name="FillerCells">
                <xsl:with-param name="cellCount" select="$cellCount - 1"/>
              </xsl:call-template>
            </xsl:if>
          </xsl:template>
    
    
        </xsl:stylesheet>
      </PackageTransform>
    </package>

    Next, the rev.recentlyviewed.xml.config_store.runtime.xml
    Code:
    <root>
      <System>
        <IsAdminSite>False</IsAdminSite>
        <IsAdminSiteInt>0</IsAdminSiteInt>
        <CustomerID>58644</CustomerID>
        <DefaultVATSetting>1</DefaultVATSetting>
        <CustomerVATSetting>1</CustomerVATSetting>
        <UseVATSetting>1</UseVATSetting>
        <CustomerLevelID>0</CustomerLevelID>
        <CustomerLevelName>
        </CustomerLevelName>
        <CustomerFirstName>
        </CustomerFirstName>
        <CustomerLastName>
        </CustomerLastName>
        <CustomerFullName>
        </CustomerFullName>
        <SubscriptionExpiresOn>
        </SubscriptionExpiresOn>
        <CustomerRoles>NoSubscription,NotRegistered</CustomerRoles>
        <IsAdminUser>False</IsAdminUser>
        <IsSuperUser>False</IsSuperUser>
        <VAT.Enabled>false</VAT.Enabled>
        <VAT.AllowCustomerToChooseSetting>true</VAT.AllowCustomerToChooseSetting>
        <LocaleSetting>en-US</LocaleSetting>
        <CurrencySetting>USD</CurrencySetting>
        <CurrencyDisplayLocaleFormat>
        </CurrencyDisplayLocaleFormat>
        <WebConfigLocaleSetting>en-US</WebConfigLocaleSetting>
        <SqlServerLocaleSetting>en-US</SqlServerLocaleSetting>
        <PrimaryCurrency>USD</PrimaryCurrency>
        <PrimaryCurrencyDisplayLocaleFormat>
        </PrimaryCurrencyDisplayLocaleFormat>
        <Date>6/10/2010</Date>
        <Time>3:03 PM</Time>
        <SkinID>1</SkinID>
        <AffiliateID>0</AffiliateID>
        <IPAddress>24.172.30.82</IPAddress>
        <QueryStringRAW>
        </QueryStringRAW>
        <UseStaticLinks>
        </UseStaticLinks>
        <PageName>p-2-avaya-5402-2-line-digital-phone.aspx</PageName>
        <FullPageName>/p-2-avaya-5402-2-line-digital-phone.aspx</FullPageName>
        <XmlPackageName>rev.recentlyviewed.xml.config</XmlPackageName>
        <StoreUrl>http://216.27.94.45/</StoreUrl>
        <CurrentDateTime>Thu, 10 Jun 2010 19:03:05 GMT</CurrentDateTime>
        <CustomerIsRegistered>false</CustomerIsRegistered>
        <StoreID>1</StoreID>
        <FilterProduct>False</FilterProduct>
        <FilterEntity>False</FilterEntity>
        <FilterTopic>False</FilterTopic>
        <FilterNews>False</FilterNews>
        <RequestedPage>p-2-avaya-5402-2-line-digital-phone.aspx</RequestedPage>
        <RequestedQuerystring>
        </RequestedQuerystring>
      </System>
      <QueryString />
      <Form />
      <Session>
        <catid>17</catid>
      </Session>
      <Cookies>
        <Referrer>http://216.27.94.45/</Referrer>
        <ASPDNSFGUID>85275CE8905FDC30658094E5934DA8A3775AEBA4BF927E8649989A437BED90F695E803CD2B097ADBB4EF3A253BFBD46FB9E2E556950C638275F0906C1594FBE18890E08384D5F77D749C8CCCBBC639E9CEFEDA5CE04B0607AFB1D620CE4BF6CE0EAF0DBE6A4B527BE91829595525B63F2F69B9FA7F5C31396DFCE0963B183886</ASPDNSFGUID>
      </Cookies>
      <ServerVariables>
        <HTTP_HOST>216.27.94.45</HTTP_HOST>
        <HTTP_USER_AGENT>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9 (.NET CLR 3.5.30729)</HTTP_USER_AGENT>
        <AUTH_TYPE>Forms</AUTH_TYPE>
        <AUTH_USER>d97784bd-b17a-43b0-a9d1-2115eef718c7</AUTH_USER>
        <AUTH_PASSWORD>
        </AUTH_PASSWORD>
        <HTTPS>off</HTTPS>
        <LOCAL_ADDR>216.27.94.45</LOCAL_ADDR>
        <PATH_INFO>/p-2-avaya-5402-2-line-digital-phone.aspx</PATH_INFO>
        <PATH_TRANSLATED>C:\websites\IHaveIT\wwwroot\p-2-avaya-5402-2-line-digital-phone.aspx</PATH_TRANSLATED>
        <SCRIPT_NAME>/p-2-avaya-5402-2-line-digital-phone.aspx</SCRIPT_NAME>
        <SERVER_NAME>216.27.94.45</SERVER_NAME>
        <SERVER_PORT_SECURE>0</SERVER_PORT_SECURE>
        <HTTP_CLUSTER_HTTPS>
        </HTTP_CLUSTER_HTTPS>
      </ServerVariables>
      <Runtime>
        <IPAddress>24.172.30.82</IPAddress>
        <FilterProduct>False</FilterProduct>
        <IsAdminSite>False</IsAdminSite>
        <StoreUrl>http://216.27.94.45/</StoreUrl>
        <FilterNews>False</FilterNews>
        <CurrencySetting>USD</CurrencySetting>
        <FilterEntity>False</FilterEntity>
        <IsSuperUser>False</IsSuperUser>
        <StoreID>1</StoreID>
        <CustomerLastName>
        </CustomerLastName>
        <PrimaryCurrency>USD</PrimaryCurrency>
        <WebConfigLocaleSetting>en-US</WebConfigLocaleSetting>
        <CurrencyDisplayLocaleFormat>
        </CurrencyDisplayLocaleFormat>
        <XmlPackageName>rev.recentlyviewed.xml.config</XmlPackageName>
        <VAT.AllowCustomerToChooseSetting>True</VAT.AllowCustomerToChooseSetting>
        <AffiliateID>0</AffiliateID>
        <CustomerIsRegistered>false</CustomerIsRegistered>
        <SkinID>1</SkinID>
        <FilterTopic>False</FilterTopic>
        <QueryStringRAW>
        </QueryStringRAW>
        <LocaleSetting>en-US</LocaleSetting>
        <CustomerLevelName>
        </CustomerLevelName>
        <FullPageName>/p-2-avaya-5402-2-line-digital-phone.aspx</FullPageName>
        <CustomerLevelID>0</CustomerLevelID>
        <DefaultVATSetting>1</DefaultVATSetting>
        <SqlServerLocaleSetting>en-US</SqlServerLocaleSetting>
        <CustomerVATSetting>1</CustomerVATSetting>
        <IsAdminUser>False</IsAdminUser>
        <Date>6/10/2010</Date>
        <CustomerRoles>NoSubscription,NotRegistered</CustomerRoles>
        <VAT.Enabled>False</VAT.Enabled>
        <UseStaticLinks>False</UseStaticLinks>
        <Time>3:03 PM</Time>
        <SubscriptionExpiresOn>
        </SubscriptionExpiresOn>
        <CustomerFirstName>
        </CustomerFirstName>
        <PageName>p-2-avaya-5402-2-line-digital-phone.aspx</PageName>
        <UseVATSetting>1</UseVATSetting>
        <CustomerFullName>
        </CustomerFullName>
        <PrimaryCurrencyDisplayLocaleFormat>
        </PrimaryCurrencyDisplayLocaleFormat>
        <IsAdminSiteInt>0</IsAdminSiteInt>
      </Runtime>
      <RecentlyViewedProducts />
    </root>
    Lastly, the rev.recentlyviewed.xml.config_store.runtime.sql
    Code:
    ************************************  SQL Statement and parameters for query RecentlyViewedProducts  ************************************
    
    declare @productid Int
    declare @customerGUID NVarChar
    declare @invFilter Int
    declare @recentlyViewedProductsNumToDisplay Int
    declare @StoreID Int
    declare @FilterProduct Bit
    
    set @productid = 4
    set @customerGUID = ''
    set @invFilter = -1
    set @recentlyViewedProductsNumToDisplay = 5
    set @StoreID = 1
    set @FilterProduct = False
    
    
    exec dbo.aspdnsf_GetRecentlyViewedProducts
    			    @productID,
    				  @customerGUID,
    				  @invFilter,
    				  @recentlyViewedProductsNumToDisplay,
    				  @storeID,
              @FilterProduct
    The rev.recentlyviewed.xml.config_store.xfrm.xml contains no debug output. Also, including the entity helpers appears to have no effect.

  6. #6
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Hi,

    Yes unless my eyes are deceiving me, no product id is being passed in the /root/Runtime block so the stored procedure is using its default value (4).

    Two ways I can think to solve this...

    1. What we've done for other v9 sites where the ID is needed (e.g. CategoryID or ProductID) is to write a small custom XSLT module that simply extracts the ID from a valid page name, e.g. p-1234-product-name.aspx returns '1234'.

    or

    2. If you need this to work within just the product page... rather than calling inside an <ASP:literal/>, try calling if from within your product page XML, something like this:

    <xsl:value-of select="aspdnsf:XmlPackage('rev.recentlyviewed.xml .config','productid=/Products/Product/ProductID')" disable-output-escaping="yes"/>

    Keep debug on and see if your recent products XML is being passed a productid runtime value. I'm typing from memory but I think this is a nice undocumented feature of the aspdnsf:XmlPackage to be able to pass custom runtime parameters.

  7. #7
    cfwebmasters is offline Junior Member
    Join Date
    Mar 2007
    Posts
    26

    Default

    Actually, I think the feature is documented. It's a second parameter passed in when calling an xml package (!$ Tokens:XMLPackage, xml.package.config, param=foo!)

    Two main problems, though:

    First, Recently viewed must be visible on every page. That includes the home page.

    Second, the default productid is actually 0. I hard-coded it to 4, which is a valid produt id in the store (currently for an HP HDX18t). So, even by hard-coding the value to a valid product did not seem to resolve the issue.

    I'll try your other suggestion, where a custom XML package calls this package and passes the id as a runtime parameter and see what happens.

    Thanks for the reply.

  8. #8
    webopius is offline Senior Member
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    440

    Default

    Hi

    I just did a double check and in our version of 9.0.1.3, aspdnsf_GetRecentlyViewedProducts is defined with a parameter of '@CustomerViewID' not '@customerGUID'

    Could you double check your database definition for this procedure and perhaps run it directly from the database with those parameters?

    Adam

  9. #9
    cfwebmasters is offline Junior Member
    Join Date
    Mar 2007
    Posts
    26

    Default

    Sorry for the delay in replying...things have been busy, so I'm just getting back to this project.

    I will check that SP and verify the parameters, as well as run it directly in SQL, and post back the results.