Jump to content

Adding new field in orders tab


teralite

Recommended Posts

Hi all!

 

Im trying to set up a new field in the orders tab where i can connect a seller to a customer. I want this to be visible in the orders tab so i can make a search on each sellers name and see what orders they have.

 

I have created a new field in DB called sellers and i added it to ps_customers.

 

Now i try this in AdminOrdersController.php but when i type in the code the whole order page is just blank.

 

Anyone know what im doing wrong here?

 

$this->_join = '
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
        LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
        LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`sellers` = a.`sellers`)';
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';

 

 

$this->fields_list = array(
        'id_order' => array(
            'title' => $this->l('ID'),
            'align' => 'center',
            'width' => 25
        ),
        'reference' => array(
            'title' => $this->l('Reference'),
            'align' => 'center',
            'width' => 65
        ),
        'sellers' => array(
            'title' => $this->l('Sellers'),
            'align' => 'center',
            'width' => 65

        ),
        'new' => array(
            'title' => $this->l('New'),
            'width' => 25,
            'align' => 'center',
            'type' => 'bool',
            'tmpTableFilter' => true,
            'icon' => array(
                0 => 'blank.gif',
                1 => array(
                    'src' => 'note.png',
                    'alt' => $this->l('First customer order'),
                )

Link to comment
Share on other sites

I don't know if this is the only problem that makes your page go blind, but you used the same alias for ps_customer table : c

$this->_join = '
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
        LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
        LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`sellers` = a.`sellers`)';
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';

Second thing is that your extra LEFT JOIN is useless. You already have a join with ps_customer table.

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...