Zen Cart Logo
Forums / General Questions / Create a query based based on price

Create a query based based on price

Views: 545

Results 1 to 7 of 7
25 Feb 2014, 3:00 PM
#1
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Create a query based based on price

Is there a way to create a query to display a listing page for products from a particular category/sub-category; which the product prices are less than a certain dollar amount?

25 Feb 2014, 3:41 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Create a query based based on price

Where does the "category/sub-category" value get set? Is it a cPath specification, e.g. category 1/subcategory 5 represented as 1_5?

25 Feb 2014, 4:04 PM
#3
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Create a query based based on price

Thanks for the reply.

Yes it is cPath specific.

http: // MyDomain . com/index.php?main_page=index&cPath=22
or
http: // MyDomain . com/index.php?main_page=index&cPath=22_10

25 Feb 2014, 4:47 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Create a query based based on price

Is this a completely stand-alone page you want, or more like limiting the category page to just a certain price range on demand?

If the latter, it would pretty much be a matter of inserting something like a " and products_price < xx" in the "where" clause of an existing query.

25 Feb 2014, 8:03 PM
#5
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Create a query based based on price

gjh42:

Is this a completely stand-alone page you want, or more like limiting the category page to just a certain price range on demand?

If the latter, it would pretty much be a matter of inserting something like a " and products_price < xx" in the "where" clause of an existing query.

It would be wonderful to have a stand alone page! I just don't know how involved that would be?

But for now limiting the display of category page for product prices less than xx.xx would just do.

Can this be done from URL? Or is it more involved than that?

Don't laugh, but I tried this and did not produce anything.
index.php?main_page=index&cPath=22_10&products_price%3C50.00 (%3C is <)

Thanks Glen.

25 Feb 2014, 8:21 PM
#6
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Create a query based based on price

Not possible from the URL. You would have to alter a query in the file that fetches the listing content. If you want to allow user choice of filtered or unfiltered, or even better the price breakpoint, you would have to additionally build a form that would re-call the page with the new info in the URL, which you would build code to extract and use in the query (with appropriate sanitization so a user couldn't input something malicious).

The "standalone page" you would like would still be a category listing page, wouldn't it? Or would it be a special "low-price" page that would not look like a standard page? In either case you would use the product listing page as a base, to clone and modify for the special page, or to add conditional code to use the limit on the standard page.

25 Feb 2014, 8:29 PM
#7
kevin205 avatar

kevin205

Totally Zenned

Join Date:
Dec 2012
Posts:
607
Plugin Contributions:
0

Re: Create a query based based on price

Got it thanks.