php - PrestaShop: inner join to show customer name in a list -


i'm making prestashop 1.6 plugin can configure discount costumers, table below:

create table ps_discountbycustomer (     id_discountbycustomer int not null auto_increment         primary key,     id_customer int not null,     date_start datetime not null,     date_end datetime not null,     use_percentage bit not null,     percentage_order float not null,     percentage_shipping float not null,     value_order float not null,     value_shipping float not null ); 

my module list: enter image description here

how i'm making controller class:

class admindiscountbycustomercontroller extends admincontroller {      public function __construct()     {         $this->bootstrap  = true;         $this->table = 'discountbycustomer';         $this->classname = 'discountbycustomermodel';         $this->identifier = 'id_discountbycustomer';          parent::__construct();          $this->lang = false;          $this->_join = 'inner join '._db_prefix_.'customer c on (a.id_customer = c.id_customer)';          // building list of records stored within "test" table         $this->fields_list = array( //            'id_discountbycustomer' => [ //                'title' => $this->l('id'), //                'align' => 'center', //                'width' => 25 //            ],             'id_customer' => [                 'title' => $this->l('customer'),                 'width' => 'auto'             ],             'date_start' => [                 'title' => $this->l('starts'),                 'width' => 'auto',                 'type' => 'date'             ],             'date_end' => [                 'title' => $this->l('ends'),                 'width' => 'auto',                 'type' => 'date'             ],             'use_percentage'   => [                 'title'  => $this->l('use percentage'),                 'active' => 'use_percentage',                 'align'  => 'text-center',                 'class'  => 'fixed-width-sm'             ],             'percentage_order'   => [                 'title' => $this->l('order %'),                 'width' => 'auto',                 'type' => 'float'             ],             'percentage_shipping'   => [                 'title' => $this->l('shipping %'),                 'width' => 'auto',                 'type' => 'float'             ],             'value_order'   => [                 'title' => $this->l('order %'),                 'width' => 'auto',                 'type' => 'float'             ],             'value_shipping'   => [                 'title' => $this->l('shipping %'),                 'width' => 'auto',                 'type' => 'float'             ],         );          // adds multiple deletion button         $this->bulk_actions = array(             'delete' => array(                 'text' => $this->l('delete selected'),                 'confirm' => $this->l('delete selected items?')             )         );          parent::__construct();     } } 

my problem don't know how can add costumer column in $this->fields_list array can costumer's name displayed in list.

how can that? i'm using prestashop 1.6.1.12. help

you need add select concat name

$this->_select = 'a.*, concat(c.`firstname`, \' \', c.`lastname`) `customer`'; 

then, instead of field id_customer use customer:

'customer' => [     'title' => $this->l('customer'),     'width' => 'auto' ], 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -