Dynamic sorting ubercart products by price use views taxonomy_term

Use hook_views_query_alter(&$view, &$query), formapi create sorting form, Jquery add the on change event to submit the form.
This method can also used in other views sorting.
The hook_views_query_alter
function mymodule_views_query_alter(&$view, &$query) {
$sort_views = array(

    if(in_array($view->name, $sort_views) && !drupal_is_front_page()) {
$sorting_criteria = $_SESSION[‘sorting_criteria’];
//  drupal_set_message(t(‘sorting criteria is: ‘.$sorting_criteria));
// drupal_set_message(‘session data of sorting criteria is: ‘. $sorting_criteria);
if(trim($sorting_criteria)) {
$query->orderby = array_merge(array($sorting_criteria), $query->orderby);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s