Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Sorting Products by Price DESC?


pafranklin

Recommended Posts

Posted

Hi, I have read the forums for what seems to be hours and cannot quite find the solution to my question.

 

I have successfully changed the sort / display of products in any given category to by price (DESC) without a hitch. However some categories have more than one page which is where I have a slight problem.

 

The first page displays correcly with the first 20 products arranged by price (descending). The problem is that when clicking on page 2 or "next" the product display switches to alphabetical.

 

I have noticed that when look at the URL page one reads http://www.mydomain.com/categoryxyz.html

 

When clicking Page 2 or next this changes to something like http://www.mydomain.com/categoryxyz.html?page=2&sort=2a

 

This sort of suggests my problem lies in the "sort" function somewhere? Basically I need to sort by price (DESC) and for this to be carried over to all future pages...........

 

I have been struggling with this for some time so would be really grateful for a steer in the right direction.

 

Thank you.

You will never learn if you don't try. And boy am I trying....!

Posted

This is the code you want to edit:

$listing_sql .= ' order by ';

switch ($column_list[$sort_col-1]) {

case 'PRODUCT_LIST_MODEL':

$listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

break;

case 'PRODUCT_LIST_NAME':

$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');

break;

case 'PRODUCT_LIST_MANUFACTURER':

$listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

break;

case 'PRODUCT_LIST_QUANTITY':

$listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

break;

case 'PRODUCT_LIST_IMAGE':

$listing_sql .= "pd.products_name";

break;

case 'PRODUCT_LIST_WEIGHT':

$listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

break;

case 'PRODUCT_LIST_PRICE':

$listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";

break;

I guess you want to change the d to and a.

case 'PRODUCT_LIST_PRICE':

$listing_sql .= "final_price " . ($sort_order == 'a' ? 'desc' : '') . ", pd.products_name";

break;

If that doesn't do it try to mess around with this code a little.

Other great Open Source (Free) programs: (Free as in free speech not free beer)

The Gimp - An image program. | Firefox - All you have to do is add the Web Developer add-on to make this web browser complete. | FileZilla - An ftp program. | Inkscape - A good program to create images with. | Thunderbird - An email program. | Openoffice.org - An office suite that is compatible with MS Office. | Abiword - Another office suite. | Audacity - A sound recording tool. | ddp's Picks | Wordpress - An easy to use blogging software. | Joomla - An easy to use CMS that has ecommerce plug-ins. | Drupal - Another CMS

How do I find these programs? Google Search!

Posted

Hi natewlew,

 

Thanks for the suggestions and good news - I tthink that I have found another solution (cortesy of my Christmas investment - Monika's Deep Inside OSCommerce The Cookbook!

 

I edited the index.php page (using recipe 21 sorting product listing by date added) and simply commented out the following line......

 

// $HTTP_GET_VARS['sort'] = $i+1 . 'a';

 

It worked a treat and means that I can simply sort products across multiple pages by amount (either ASC or DESC).

 

Ihope that this helps someone else too!

You will never learn if you don't try. And boy am I trying....!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...