Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how to show new items first in product listing


minghoo

Recommended Posts

hi guys,

 

how can i change the code in index.php to show new items first in product listing page?

 

 

 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 pd.products_name ";
         break;
       }
     }

 

i know how to sort order by product model number or price, but how can i sort product by date, which means new added items show first on product listing page.

 

 

Thanks

 

sean

Link to comment
Share on other sites

and aslo i tried to sort by model number:

 

  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_MODEL') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by p.products_model";
         break;
       }
     }

 

but this is not desc order, so i change this code to this:

 

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_MODEL') {
         $HTTP_GET_VARS['sort'] = $i+1 . 'a';
         $listing_sql .= " order by p.products_model desc";
         break;
       }
     }

 

 

Somehow this is only to work on the first page, but not 2 or 3 pages.

 

Anyone any idea how to do it?

 

Thanks

 

sean

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...