Jump to content

Add column to order list in the backend


Daniel Patilea
 Share

Recommended Posts

Hello,

 

Does anyone know how can i add an additional tab to the order list in the backend?

I want to add a tab with the carrier picked for that order.

Is this something that has to do with AdminOrdersController.php file?

 

Here's what i mean:

 

LFr27gX.png

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

 

I've tried your tutorial but it replaces all the current tabs and adds another some similar ones but with another design, like the one used ok ps 1.5.

Then i added this code for the carrier tab:

'carrier' => array(
            'title' => $this->l('Carrier'),
            'align' => 'center',
            'width' => 45
        ),

And it throws an error:

Bad SQL query
Unknown column 'carrier' in 'field list'

I guess i should add carrieri to the query in order to work. Can you please help me?

Edited by iDan (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 3 months later...

I've also added this sql query:

INNER JOIN `'._DB_PREFIX_.'carrier` carrier ON carrier.id_carrier = a.id_carrier

Everything is good now.

Thanks for your help Nemo!

HI

I changed the code as you mentioned. but it shows the carrier ID , is there a way to show the Carrier Name ? I appreciated if you can help me I already spend 5 hours figuring out but no result.

 

Thanks

Share this post


Link to post
Share on other sites

HI

I changed the code as you mentioned. but it shows the carrier ID , is there a way to show the Carrier Name ? I appreciated if you can help me I already spend 5 hours figuring out but no result.

 

Thanks

You have to select the name in the query, not the id.

Add to the query, where you select the data, the following field: carrier.name and it should work

  • Like 1

Share this post


Link to post
Share on other sites

You have to select the name in the query, not the id.

Add to the query, where you select the data, the following field: carrier.name and it should work

Thank you for your post.

I tried that already but then the order page shows no order, all the previuse order are gone.

I use the following codes: 

 
$this->_select = '
a.id_carrier AS carrier,
 
--///--

 

INNER JOIN `'._DB_PREFIX_.'carrier` carrier ON carrier.name = a.id_carrier

 

---///---

 

 'carrier' => array(
                'title' => $this->l('Carrier')
            ),
Edited by heidardg (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

 

Thank you for your post.

I tried that already but then the order page shows no order, all the previuse order are gone.

I use the following codes: 

 
$this->_select = '
a.id_carrier AS carrier,
 
--///--

 

INNER JOIN `'._DB_PREFIX_.'carrier` carrier ON carrier.name = a.id_carrier

 

---///---

 

 'carrier' => array(
                'title' => $this->l('Carrier')
            ),

 

Here's my code:

$this->_select = '
        a.id_currency,
        a.id_order AS id_pdf,
        a.id_carrier,
        carrier.name as crname,
        CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
        osl.`name` AS `osname`,
        os.`color`,
        IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
        country_lang.name as cname,
        IF(a.valid, 1, 0) badge_success';

        $this->_join = '
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
        INNER JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery

        INNER JOIN `'._DB_PREFIX_.'carrier` carrier ON carrier.id_carrier = a.id_carrier

        INNER JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country
        INNER JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.')
        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.')';
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';

and

$this->fields_list = array_merge($this->fields_list, array(
            'crname' => array(
                'title' => $this->l('Carrier'),
                'havingFilter' => false,
            ),
        ));
  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

 

Here's my code:

$this->_select = '
        a.id_currency,
        a.id_order AS id_pdf,
        a.id_carrier,
        carrier.name as crname,
        CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
        osl.`name` AS `osname`,
        os.`color`,
        IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new,
        country_lang.name as cname,
        IF(a.valid, 1, 0) badge_success';

        $this->_join = '
        LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
        INNER JOIN `'._DB_PREFIX_.'address` address ON address.id_address = a.id_address_delivery

        INNER JOIN `'._DB_PREFIX_.'carrier` carrier ON carrier.id_carrier = a.id_carrier

        INNER JOIN `'._DB_PREFIX_.'country` country ON address.id_country = country.id_country
        INNER JOIN `'._DB_PREFIX_.'country_lang` country_lang ON (country.`id_country` = country_lang.`id_country` AND country_lang.`id_lang` = '.(int)$this->context->language->id.')
        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.')';
        $this->_orderBy = 'id_order';
        $this->_orderWay = 'DESC';

and

$this->fields_list = array_merge($this->fields_list, array(
            'crname' => array(
                'title' => $this->l('Carrier'),
                'havingFilter' => false,
            ),
        ));

Finally I did it,. Thank you so much. 

 

could you pls advice how I add the Zip code? 

  • Like 1

Share this post


Link to post
Share on other sites

  • 1 year later...
  • 4 years later...
  • 8 months later...
  • 7 months later...
On 9/9/2021 at 10:32 AM, Janett said:

Here a demo module to add a column with carrier : https://github.com/Matt75/displayordercarrier/releases/latest

Hello, I'm sorry if the question seems stupid, but how do you install this module ?
I tried to install the zip, Presta said it's not a module.

I tried in FTP and it broke my modules, error 500. I had to delete it in order to remove the error 500.

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More