Contributions

Features (Category Index)
Search: 

Sort by price(if you use mod rewrite)

I wanted a contrib to help me sort my products by price and since i couldn't find one to work with mod rewrite i made one myself.


// Sort by price if you have mod rewrite
// Look for this code in catalog/index.php at around line 193

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;

//Replace this above line $HTTP_GET_VARS['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";

//With this line $HTTP_GET_VARS['sort'] = $i+2 . 'a';
$listing_sql .= " order by final_price";

Expand All / Collapse All

Sort by price(if you use mod rewrite) 29 May 2007

I wanted a contrib to help me sort my products by price and since i couldn't find one to work with mod rewrite i made one myself.


// Sort by price if you have mod rewrite
// Look for this code in catalog/index.php at around line 193

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;

//Replace this above line $HTTP_GET_VARS['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";

//With this line $HTTP_GET_VARS['sort'] = $i+2 . 'a';
$listing_sql .= " order by final_price";

Note: Contributions are used at own risk.