Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / how can I sort products into assending price order in one category only?

how can I sort products into assending price order in one category only?

Locked

Started by sushigal on 23 Jun 2010, 9:02 AM · Views: 855

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
23 Jun 2010, 9:02 AM
#1
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Post #1 by sushigal

is there a way to sort products in particular categories so that they appear on the product listing page from lowest to highest price or vice versa.
I'm aware there may be an option in admin for this to be applied for products in all categories but we do not want this, we want to be able to only apply this to one category at the moment.

I know I could achieve this by manually giving the products in this category a number in order to sort them into lowest up to highest price but this would take ages as I'd have to note down which is cheapeast then the next highest etc etc and give them a number in relation to this, which would take forever and I day in this particular category as there's so many products.

If anyone has any idea of how you can sort them into price order just in one category id be most grateful.

Many thanks

23 Jun 2010, 4:36 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #2 by ajeh

You could customize the default_filter.php where it is set, when not set by the customer:

// set the default sort order setting from the Admin when not defined by customer
  if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
    $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Jun 2010, 8:49 AM
#3
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Post #3 by sushigal

hi thanks for your response, which file would I need to edit and what would I need to put in, i really dont know. Also would this only affect one category as ive requested?

P.s

I have an urgent issue I have posted about already that im wondering if you can help with...If you see at the bottom of every page, theres a blue tool bar with the link 'home' id also like to add in a link called 'top of page' but I really have no idea which file I need to edit to put this in, if you could help me on this id be forever grateful! :smile:

24 Jun 2010, 1:53 PM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #4 by ajeh

You need to edit the file:
/includes/index_filters/default_filter.php

Where the code is that I posted you need to test for the current categories_id and change the sort order, when the customer has not set a sort order to use the one needed for price, if it is the category that you want sorted by price ...

The code I posted is where the sort order is set to the default sort order setting when the customer has not changed the sort order themselves ...

Without actually seeing your site it is hard to guess what settings are needed to manage this as I do not know the categories_id that you want to sort by price nor do I know the sort setting for the price column on your site ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Jun 2010, 3:35 PM
#5
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Post #5 by sushigal

Hi, thanks again for your reply, my site is at http://www.thegreatgiftshop.co.uk/zencart hope you can help a bit more now from seeing this.

Tahnk you very much indeed.

24 Jun 2010, 3:58 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #6 by ajeh

Let's say you want categories_id 10 to sort by Price but all the others to use your default setting ...

You can customize the code to read:

// bof: set sort order to Price for categories_id 10 when sort order is not set by customer
  if (!isset($_GET['sort']) and $current_category_id == 10) {
    $_GET['sort'] = '3a';
  }
// eof: set sort order to Price for categories_id 10 when sort order is not set by customer

// set the default sort order setting from the Admin when not defined by customer
  if (!isset($_GET['sort']) and PRODUCT_LISTING_DEFAULT_SORT_ORDER != '') {
    $_GET['sort'] = PRODUCT_LISTING_DEFAULT_SORT_ORDER;
  }

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Jun 2010, 6:17 PM
#7
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Post #7 by sushigal

Ah I see, ok thank you so much! I'll try that asap. :D

25 Jun 2010, 1:32 PM
#8
sushigal avatar

sushigal

Zen Follower

Join Date:
Mar 2009
Posts:
435
Plugin Contributions:
0

Post #8 by sushigal

Brilliant, thats just the job, inserted that code a couple of times so that two categories I wanted are now sorted lowest to highest by default on the product listing.

Thanks! :clap:

25 Jun 2010, 2:00 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #9 by ajeh

Thanks for the update that this is now working for you to manage to sort 2 of your categories in a different manner than the default sort on the listings ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!