Jump to content

Fields_list helper ['list'] custom field


Terrans

Recommended Posts

Hi!

This __construct
 

$this->table = 'customer_balance';
        $this->className = 'customerbalance';
        $this->module = 'customerbalance';
        $this->explicitSelect = true;
        $this->allow_export = true;
        $this->lang = false;
        $this->bootstrap = true;
        $this->context = Context::getContext();

 

$customers = Customer::getCustomers();
        foreach ($customers as $customer)
            $names_array[$customer['id_customer']] = $customer['firstname'].' '.$customer['lastname'];

$this->fields_list = array(
            'id_customer_balance' => array(
                'title' => $this->l('Id'),
                'align' => 'text-center',
                'class' => 'fixed-width-xs'
            ),
            'id_customer' => array(
                'title' => $this->l('Name'),
                'align' => 'center',
                'type' => 'select',
                'list' => $names_array,
                'filter_key' => 'id_customer',
                'filter_type' => 'int',
                'order_key' => 'id_customer'
            ),
            'balance' => array(
                'title' => $this->l('Balance'),
                'align' => 'text-right',
                'type' => 'price',
                'currency' => true/*,
                'callback' => 'setOrderCurrency'*/
            )
        );
        parent::__construct();

The filter listing the names, but the rows display id_customer not the names, why?
What do I do badly?

Please help.

 

Link to comment
Share on other sites

Hi Terrans,

 

Firstly, if you set explicitSelect helper list option as true, you should declare that select. Second, when you write (...) 'id_customer' => array on your fields list, you are telling to the helper to display the column id_customer - exactly what's happening.

 

Hope it helps

Rubens Cury

  • Like 1
Link to comment
Share on other sites

Hi Terrans,

 

Firstly, if you set explicitSelect helper list option as true, you should declare that select. Second, when you write (...) 'id_customer' => array on your fields list, you are telling to the helper to display the column id_customer - exactly what's happening.

 

Hope it helps

Rubens Cury

Hi Rubens Cury,

 

Thanks. I changed the 'id_customer' to 'customer' and paste this code:

 

 $this->_select = '
a.id_customer,
CONCAT(c.`firstname`, \' \', c.`lastname`) AS `customer`';
 
        $this->_join = '
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)';
        $this->_orderBy = 'id_customer';
        $this->_orderWay = 'ASC';
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...