Amit Singh
Amit Singh

Reputation: 2275

sort by size opencart

I'm trying to add a new sorting method i'e "sort by height" in opencart.

A.location is:catalog/model/catalog/product.php -> added p.height here

$sort_data = array(
'pd.name',

'p.model',

'p.quantity',

'p.price',

'rating',

'p.sort_order',

'p.date_added',

'p.height'
);  

B. in the same file

elseif($data['sort'] == 'p.height' ){   

    $sql .= " ORDER BY(" . $data['sort'] . ")ASC";

       /*$sql .= "SELECT * FROM". DB_PREFIX . "product p ORDER BY p.height DESC";*/
}

C. location is:/catalog/controller/product/category.php

        $this->data['sorts'][] = array(

            'text'  => $this->language->get('text_size_asc'),

            'value' => 'height-ASC',

            'href'  => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '&sort=height&order=ASC' . $url)

        );

Result is i can see "sort by height" in option but nothing happens when i select it returns the default sort value.

Can any one suggest where i am doing wrong?

Upvotes: 0

Views: 1200

Answers (1)

Jay Gilford
Jay Gilford

Reputation: 15151

It should be p.height-ASC not height-ASC For the 'value' key otherwise it does not recognise it. You also need to change &sort=height to &sort=p.height in the 'url' key

Upvotes: 1

Related Questions