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 4 of 4

Thread: price ranges

  1. #1
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default price ranges

    I am looking to put the prices of product search results into price ranges. I currently have it grouped by price but am not sure how to get it to actually group by a range dynamically. Any suggestions?

    Here is what I have currently to group by price.
    Code:
    <xsl:key name="variants-by-price" match="Products/Product" use="Price" />
    <h3>Price Range</h3>
              <ul>
              <xsl:for-each select="/root/Products/Product[count(. | key('variants-by-price', Price)[1]) = 1]">
                <xsl:sort select="Price"></xsl:sort>
                <xsl:variable name="ProductPrice" select="Price" />
                <li><a href="">$<xsl:value-of select="format-number($ProductPrice,'###,###.00')" disable-output-escaping="yes" /></a> <small>(<xsl:value-of select="count(/root/Products/Product[Price = $ProductPrice])" />)</small></li>
              </xsl:for-each>
              </ul>

  2. #2
    mmcgeachy is offline Senior Member
    Join Date
    Sep 2008
    Posts
    174

    Default

    position() logic may work for you. Try something like this:
    Code:
    <xsl:key name="variants-by-price" match="Products/Product" use="Price" />
    <h3>Price Range</h3>
    <ul>
    <xsl:for-each select="/root/Products/Product[count(. | key('variants-by-price', Price)[1]) = 1]">
    <xsl:sort select="Price"></xsl:sort>
    <xsl:variable name="ProductPrice" select="Price" />
    	<xsl:if test="position() = 1">
    	<li><a href="">$<xsl:value-of select="format-number($ProductPrice,'###,###.00')" disable-output-escaping="yes" /></a> <small>(<xsl:value-of select="count(/root/Products/Product[Price = $ProductPrice])" />)</small></li>
    	</xsl:if>
    	<xsl:if test="position() = last()">
    		<li><a href="">$<xsl:value-of select="format-number($ProductPrice,'###,###.00')" disable-output-escaping="yes" /></a> <small>(<xsl:value-of select="count(/root/Products/Product[Price = $ProductPrice])" />)</small></li>
    	</xsl:if>
    </xsl:for-each>
    </ul>

  3. #3
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    Thanks for your reply mmcgeachy. I am looking for something a little different though. I'm looking to show multiple price ranges for the products so the customer can limit to that group.

    i.e.
    $0 - $10
    $10.01 - $50
    etc

    This would be dynamic ranges based on the products in the results.

  4. #4
    chrismartz is offline Senior Member
    Join Date
    Apr 2010
    Posts
    339

    Default

    Anyone have any suggestions?