
Originally Posted by
MIKEYFM
This is exactly what I wanted to get the category listing back but it seems to break the sort filter and the listing the products by cheapest to highest price. Or the old to new . I am not sure if you can have both. It would be good if you can as the price low to high is a nice feature..
Has anyone else noticed this and is there a fix somewhere that I have not been able to see on the forum/thread.
Thank you.
MG
I resolved it by doing the following:
created a file: includes/functions/extra_functions/sort_by_functions.php
PHP Code:
<?php
function order_by_sort_by_sql($sortby, $order_by = true) {
if($order_by == true){
$listing_sql = ' ORDER BY ';
}
switch ($sortby) {
case '1':
//newest
$listing_sql .= " p.products_date_added DESC ";
break;
case '3':
//price HIGH->LOW
$listing_sql .= " p.products_price DESC ";
break;
case '4':
//price LOW->HIGH
$listing_sql .= " p.products_price ASC ";
break;
case '5':
//Name ASC
$listing_sql .= " pd.products_name ASC ";
break;
case '6':
//Name DESC
$listing_sql .= " pd.products_name DESC ";
break;
case '0':
default:
//products defualt sort order
$listing_sql .= " p.products_sort_order, pd.products_name";
break;
}
return $listing_sql;
}
includes/index_filters/default_filter.php
commented out: (around line 90ish) also similarly in the includes/modules/advanced_search_results/header_php.php
PHP Code:
array('id' => 0, 'text' => 'Default Order'),
array('id' => 1, 'text' => 'Newest First'),
//array('id' => 2, 'text' => 'Most Popular'),
array('id' => 3, 'text' => 'Price (High to Low)'),
array('id' => 4, 'text' => 'Price (Low to High)'),
array('id' => 5, 'text' => 'Name (A-Z)'),
array('id' => 6, 'text' => 'Name (Z-A)'),
...
case 'PRODUCT_LIST_WEIGHT':
$listing_sql .= " order by p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
case 'PRODUCT_LIST_PRICE':
$listing_sql .= " order by p.products_price_sorter " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
break;
}
}
}
modified includes/templates/tableau/templates/tpl_modules_product_listing.php to have the
HTML Code:
<div class="sort-listings-wrapper">
look like this:
PHP Code:
<div class="sort-listings-wrapper">
<?php echo zen_draw_form('sortbyform', zen_href_link(zen_db_prepare_input($_GET['main_page']), zen_get_all_get_params(array('sortby', 'sort','keyword','search_in_description','inc_subcat','')), $request_type, false), 'get') . zen_hide_session_id();?>
<?php
echo zen_draw_hidden_field('main_page', zen_db_prepare_input($_GET['main_page']));
$sortbyparams = explode('&', zen_get_all_get_params(array('sortby', 'sort','')));
foreach($sortbyparams as $param) {
$param = explode('=', $param);
if(strlen($param[0]) > 1){
echo zen_draw_hidden_field($param[0], $param[1]);
}
}
?>
<label>Sort By:</label>
<?php
$sortby_array = array(
array('id' => 0, 'text' => 'Default Order'),
array('id' => 1, 'text' => 'Newest First'),
//array('id' => 2, 'text' => 'Most Popular'),
array('id' => 3, 'text' => 'Price (High to Low)'),
array('id' => 4, 'text' => 'Price (Low to High)'),
array('id' => 5, 'text' => 'Name (A-Z)'),
array('id' => 6, 'text' => 'Name (Z-A)'),
);
echo zen_draw_pull_down_menu('sortby', $sortby_array, $_GET['sortby'], 'onchange="this.form.submit();"');
?>
<?php echo '</form>';?>
</div><!--EOF .sort-listings-wrapper-->
<?php if($_GET['showall'] == 1) {?>
Hopefully that helps!
Bookmarks