Jump to content

Override - Customer Class - Add Extrafield


Toinou_74

Recommended Posts

Hi, 

 

I try to Add an extrafield in customer, in my case, associate employee to customer, all work in followin code, but id_employee is not update in Db.

<?php


class Customer extends CustomerCore
{
 


public $id_employee;


public function __construct($id = null)
{
Customer::$definition['fields']['id_employee'] = array('type' => self::TYPE_STRING, 'validate' => 'isString');
parent::__construct($id);
}


}
<?php
class AdminCustomersController extends AdminCustomersControllerCore
{


public function __construct()
{
parent::__construct();


$this->fields_list['id_employee'] = array('title' => $this->l('id_employee'));
}


public function renderForm()
{ 


$this->fields_form_override =  array( 
                         array(
                   'type' => 'text',
'label' => $this->l('Commercial'),'name' => 'id_employee',
'col' => '4'
               ) ); 
return parent::renderForm(); }

Could you give me hand..

 

Thanks so much.

 

 

Link to comment
Share on other sites

Hi,

 

fresh news,

 

when i add 'id_employee' in original Customer.php (override) that works well, so is not my controller but my classes Customer.php is wrong

 $this->fields_list = array_merge($this->fields_list, array(            'total_spent' => array(
                'title' => $this->l('Sales'),
                'type' => 'price',
                'search' => false,
                'havingFilter' => true,
                'align' => 'text-right',
                'badge_success' => true
 [ ...]
'id_employee' => array(
                'title' => $this->l('employee'),
                'width' => 70,
                'align' => 'center',
                'type' => 'text',
                'orderby' => true


        )


        ));

if someone can help me...

Link to comment
Share on other sites

Yes i clear cache...

 

when i override like that:

 

<?php

 

class Customer extends CustomerCore
{



public $id_employee;


public function __construct($id = null)
{
Customer::$definition['fields']['id_employee'] = array('type' => self::TYPE_STRING, 'validate' => 'isString');
parent::__construct($id);
}


}

 id_employee is not registred in db, 

 

 

and when i override all the Customer Class and i add Id_employee, that works, strange...

Edited by Toinou_74 (see edit history)
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...