I'd say you want to do something like this - pseudo-code

select distinct price from products

This returns a list like

9.99, 12.99, 25, 69, 70, 120, 199.99

Then assuming you want to use ranges like 0-10, 10-20, etc, up to some
end point, like 200+, you can loop use a query of query to see if a
price exists in the range.

<cfquery name="checkrange" dbtype="query">
select price
from prices
where price > #min# and price <= #max#
</cfquery>

If checkrange has a record count, then you show the link for that
range. It won't be hitting the db so it should be rather zippy. You
could also cache the results too since you probably don't add products
very often.

I'll add too that there are probably 1000 other ways of doing this too
- so I'm sure someone can do this even quicker. :)


On Mon, May 31, 2010 at 3:50 AM, Mike Little <[email protected]> wrote:
>
> hey guys,
>
> am looking to add a feature to my shopping cart much like magento's shop by 
> price range. bascially for a particular category, the page will render a 
> series of ranges for a user to choose based on the products in the db eg. 
> $10-20, $20-30 etc.
>
> somehow, it will only show those ranges that have products applicable. it 
> also creates the ranges from the highest and lowest priced items (which 
> admittedly gives not so helpful ranges if gap is wide!)
>
> am a bit stuck on how to go about this. has anyone created something like 
> this before that maybe able to point me in the right direction?
>
> mike
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:334140
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to