It seems its fairly easy to add any sort field you like with X-Cart 4.0.x.
Here's how I added manufacturerid to the sort by options.
1) Edit include/search.php find:
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"),
"orderby" => func_get_langvar_by_name("lbl_default"));
Replace with:
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"),
"orderby" => func_get_langvar_by_name("lbl_default"),
"mfrid" => func_get_langvar_by_name("lbl_manufacturer")
);
Now in the same file locate:
Code:
case "orderby":
$sort_string = "$sql_tbl[products_categories].orderby $direction";
break;
After this line of code add:
Code:
case "mfrid":
$sort_string = "$sql_tbl[products].manufacturerid $direction";
break;
That's it! Pretty simple and quick, and it works on most all available fields in xcart_products table as well as others if need be.
