Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product listing sort.


Guest

Recommended Posts

Posted

I have change the default of my product listings to sort by date added. I have change this by altering the following code found in index.php

 

if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {

if ($column_list[$i] == 'PRODUCT_LIST_NAME') {

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

$listing_sql .= " order by p.products_date_added";

break;

}

}

 

The problem is it displays the oldest products first. Does anyone know how I can change it to show the newest products first.

 

Regards,

Carl.

Posted

Hi there!

 

Change this line in your code from

 

$listing_sql .= " order by p.products_date_added";

 

...to....

 

$listing_sql .= " order by p.products_date_added " . ($sort_order == 'd' ? 'desc' : '');

 

OR.......

 

$listing_sql .= " order by p.products_date_added " . ($sort_order == 'a' ? 'asc' : '');

 

I can't remember which one it is :? but one of them should work the way you want it!

 

Make sure you back up before you try!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Posted

Hi,

 

For sort by price change

 

$listing_sql .= " order by pd.products_name";

 

to.....

 

$listing_sql .= " order by p.products_price";

 

 

Back up before you try!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Posted

Once againthe forum does it again. Another problem solved...

 

thanks for all hard work..

I now sort by price

 

:?

Archived

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

×
×
  • Create New...