Question: I Need To Add A Sortable Column

I Need To Add A Sortable Column

Hi. I have looked through your instructions on the documentation but it does not give me enough information on how to do what I want. I need to add a sortable column to the List Products p

MZ

Max Z

Asked
Hi. I have looked through your instructions on the documentation but it does not give me enough information on how to do what I want.

I need to add a sortable column to the List Products page. I want to add Product Type. So I can sort by Standard, Service, Combo Ect.

I went to Products.php controller but how can I alter the select statement if I don't know which tables to look in for this information.
Also what do i set the $this->data['type'] variable to?
I wish you could give me some more instructions on this so I could implement it.

thanks.
  • EG

    Enyinnaya Gift

    Answered
    You will need to modify `getProduct` function in the `Products controller` (`app\controller\admin\Products.php`), and `Product list page` in the `Product view` (`theme\default\admin\products\index.php`).


    On the Product Controller - replace `line 1530` with the code below-

    ```
    ->select($this->db->dbprefix('products') . ".id as productid, {$this->db->dbprefix('products')}.image as image, {$this->db->dbprefix('products')}.code as code, {$this->db->dbprefix('products')}.name as name, type, {$this->db->dbprefix('brands')}.name as brand, {$this->db->dbprefix('categories')}.name as cname, cost as cost, price as price, COALESCE(wp.quantity, 0) as quantity, {$this->db->dbprefix('units')}.code as unit, wp.rack as rack, alert_quantity", false)
    ```

    And replace `line 1545` with the code below

    ```
    ->select($this->db->dbprefix('products') . ".id as productid, {$this->db->dbprefix('products')}.image as image, {$this->db->dbprefix('products')}.code as code, {$this->db->dbprefix('products')}.name as name, type, {$this->db->dbprefix('brands')}.name as brand, {$this->db->dbprefix('categories')}.name as cname, cost as cost, price as price, COALESCE(quantity, 0) as quantity, {$this->db->dbprefix('units')}.code as unit, '' as rack, alert_quantity", false)
    ```

    The on the Product View list page `theme\default\admin\products\index.php` replace line 44 with the code below

    ```
    {"bSortable": false, "mRender": checkbox}, {"bSortable": false,"mRender": img_hl}, null, null, null, null, null, <?php if ($Owner || $Admin) {
    ```
  • Login to Reply