sort by size opencart

爷,独闯天下 提交于 2019-12-13 04:37:04

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/17755629/sort-by-size-opencart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!