Blog

Cubecart5

CubeCart 5 Plugin – Part Two

This is part two of our CubeCart 5 plugin tutorial allowing you to set the default sort order for products.

After following the instructions in part one you will need to create another folder in your Advanced_Settings folder called hooks and in that folder you need to create the file controller.index.php with the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

switch ($_GET['_a']) {
    case'category':
    case'saleitems':
        $sort_field = 'date_added';
        $sort_direction = 'DESC';
        
        if ($GLOBALS['config']->has('Advanced_Settings', 'product_sort_field') && $GLOBALS['config']->get('Advanced_Settings', 'product_sort_field')) { 
            $sort_field = $GLOBALS['config']->get('Advanced_Settings', 'product_sort_field');
        }
        
        if ($GLOBALS['config']->has('Advanced_Settings', 'product_sort_direction') && $GLOBALS['config']->get('Advanced_Settings', 'product_sort_direction')) { 
            $sort_direction = $GLOBALS['config']->get('Advanced_Settings', 'product_sort_direction');
        }
        if (!isset($_GET['sort']))  {
            $_GET['sort'] = array($sort_field=>$sort_direction);
            
        }
        
    break;
}

The files from this tutorial can be downloaded in zip format Advanced_Settings

Related Posts

Discussion

2 Comment(s)

  1. Jesse Whelehan

    April 5, 2012 at 3:28 am

    Outstanding post, you have pointed out some fantastic details, I likewise believe this is a very superb website.

  2. Octavio Grasmuck

    April 6, 2012 at 6:58 am

    I am impressed with this web site, rattling I am a fan.

Leave a Reply