The product list order is by name as default, that is hard coded within index.php so you must change that to alter.
The product list sort order also depends on what was clicked last, you may have noticed that annoying '+' by 'product name' in the list heading, thats supposed to tell you that clicking on that or 'product name' will change list order on product name, similarly clicking on any other heading will order list by that column.
The code that sets the default order starts aroun 200 of 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 pd.products_name";
break;
To sort by something else you must change 2 lines to the appropriate item1.
if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
change the PRODUCT_LIST_NAME to one of: PRODUCT_LIST_MODEL, PRODUCT_LIST_MANUFACTURER, PRODUCT_LIST_QUANTITY, PRODUCT_LIST_WEIGHT, PRODUCT_LIST_PRICE
2.
$listing_sql .= " order by pd.products_name";
change the pd.products_name to one of p.products_model, m.manufacturers_name, p.products_quantity, p.products_weight, final_price
If you wish to sort it reverse order you add DESC & change a to d to indicate order.
So if your wanting the default sort to be by price in descending order you would have:
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_PRICE') {
$HTTP_GET_VARS['sort'] = $i+1 . 'd';
$listing_sql .= " order by final_price desc";
break; Please dont confuse this with sorting product atributes, thats another subject & there is a post in tips dealing with it.
Hope that makes things clear.
Edited by spooks, 15 July 2008, 09:47.















