Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / How to change Search results sorter order?

How to change Search results sorter order?

Views: 575

Results 1 to 2 of 2
17 Nov 2012, 8:56 AM
#1
prettyodd avatar

prettyodd

New Zenner

Join Date:
Nov 2012
Posts:
9
Plugin Contributions:
0

How to change Search results sorter order?

in includes/modules/pages/advanced_search_result/header_php.php

I changed the code to below, but when I search on my website, the search results are still sorted by Product ID. What can I do to make the results sorted by Product added date?

/*------------------------------------------------------*/
$productsort = array();
$nsort = array('New Arrival','Item Name','Price(Low to high)','Price(High to low)','Bestselling');

for ($i=1; $i<6; $i++) {
$productsort[] = array('id' => sprintf('%2d', $i), 'text' =>$nsort[$i-1] );
}
$pagesize = array();
$pagesize[] = array('id'=>24,'text'=>24);
$pagesize[] = array('id'=>36,'text'=>36);
$pagesize[] = array('id'=>48,'text'=>48);

if(isset($_GET['productsort']) && (int)$_GET['productsort'] > 0){
switch ($_GET['productsort']){
case 2:
$product_sort = " order by pd.products_name ";
break;
case 3:
$product_sort = " order by p.products_price";
break;
case 4:
$product_sort = " order by p.products_price DESC";
break;
case 5:
$product_sort = " order by p.products_ordered DESC";
break;
default:
$product_sort = " order by p.products_date_added DESC";
}
}