You could probably duplicate what I did but substitute the field you want to sort by. I wanted to be able to sort by description. This mod was for X-Cart Gold 4.2.2.
Here is what I did:
Modify: include/search.php
1. Add description into this array. (about line 40) (note: I had to add the lbl_description label in languages)
Code:
$sort_fields = array(
"productcode" => func_get_langvar_by_name("lbl_sku"),
"title" => func_get_langvar_by_name("lbl_product"),
"price" => func_get_langvar_by_name("lbl_price"),
"description" => func_get_langvar_by_name("lbl_description"),
"orderby" => func_get_langvar_by_name("lbl_default")
);
2. Add this new case statement to the switch function for the description field. (about line 600)
Code:
case "description":
$sort_string = "$sql_tbl[products].descr $direction";
break;
modify: include/func/func.product.php
1. add description to this array(about line 320)
Code:
if (is_null($orderby_rules)) {
$orderby_rules = array (
"title" => "product",
"quantity" => "$sql_tbl[products].avail",
"orderby" => "$sql_tbl[products_categories].orderby",
"quantity" => "$sql_tbl[products].avail",
"price" => "price",
"description" => "$sql_tbl[products].descr",
"productcode" => "$sql_tbl[products].productcode");
}