Results 1 to 3 of 3

Thread: add product count to search xmlpackage

  1. #1
    Join Date
    Dec 2005
    Location
    Cherry Hill, NJ, USA
    Posts
    239

    Default add product count to search xmlpackage

    i added a little javascript to the search xml that will display how many products were returned in the search:

    add this to top of xml:
    HTML Code:
    <!-- set product count to zero -->
    <script language="JavaScript">
    <![CDATA[
    	var value = 0;
    ]]>
    </script>
    add this inside the product template
    HTML Code:
    <script language="JavaScript">
    <![CDATA[
    	value=value+1;
    ]]>
    </script>
    add this right after the call to run product template
    HTML Code:
      <script language="JavaScript">
        <![CDATA[
    		document.write('There are ' + value + ' products that match your search.<br/><br/>');
    	]]>
      </script>

  2. #2
    ASPDNSF Staff - RYacketta Guest

    Default

    Why not just count the nodes using a xpath?

    something like

    Code:
    <xsl:value-of select="count(/root/Products/Product)" />
    Tossed it inside
    Code:
    <xsl:if test="aspdnsf:AppConfigBool('Search_ShowProductsInResults')='true' and count(/root/Products/Product)>0">
    like such

    Code:
                    <xsl:if test="aspdnsf:AppConfigBool('Search_ShowProductsInResults')='true' and count(/root/Products/Product)>0">
                        <br />
                        <table width="100%" cellpadding="2" cellspacing="0" style="{concat('border-style: solid; border-width: 0px; border-color: #', aspdnsf:AppConfig('HeaderBGColor'))}">
                            <tr>
                                <td align="left" valign="top">
                                    <img align="bottom" border="0" src="{concat('skins/Skin_', aspdnsf:SkinID(), '/images/matchingproducts.gif')}"></img>
                                    <br/>
                                    Product Count: <xsl:value-of select="count(/root/Products/Product)" />

  3. #3
    Join Date
    Dec 2005
    Location
    Cherry Hill, NJ, USA
    Posts
    239

    Default

    good point. i had to count products this way because i don't think the search accounted for sale price.

    so i added this code to the product template, which checks the price range against saleprice or regular price (if there is no sale price):
    HTML Code:
    <xsl:if test="(SalePrice='0.0000' and Price&gt;=$MinPrice and Price&lt;=$MaxPrice) or (SalePrice!='0.0000' and SalePrice&gt;=$MinPrice and SalePrice&lt;=$MaxPrice)">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •