View Single Post
  #1  
Old 12-21-2005, 02:41 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default Listing newest added product first

Add the ability to sort by add_date field along with listing default by this field. Edit include/search.php and locate the following code:

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") );

Change to:
Code:
$sort_fields = array( "add_date" => func_get_langvar_by_name("lbl_date"), "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") );

Next locate:
Code:
# # Perform search and display results # $data = array();

After this above code add:

Code:
if(empty($sort)) $sort = "add_date";

Next locate:
Code:
case "productcode": $sort_string = "$sql_tbl[products].productcode $direction"; break;

Above this line add:

Code:
case "add_date": $sort_string = "$sql_tbl[products].add_date DESC"; break;

Thats it! Now all of your product listings by default will show newest products first. As well as Date field has been added to the sort options list under "Date".

Keep in mind, X-Cart admin->General Settings->Apperance: "Select the order in which products should be displayed within a category:" will be ignored with this mod in place.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote