Yzzy Posted August 6, 2012 Share Posted August 6, 2012 Good Morning all! I deal with companies who use different employees to place orders. This means I can't always know that Frank and Jane are ordering for Blah Blah Ltd. I'd like the back office ORDERS tab to display COMPANY NAME before or instead of Customer name please... Anyone have a quick link to how to do this? Yzzy x Link to comment Share on other sites More sharing options...
Yzzy Posted August 6, 2012 Author Share Posted August 6, 2012 (edited) ad.`company` AS `company`, a.id_order AS id_pdf, isn't working.. it's kicking up an SQL error... I can yet again see MANY threads all asking this same question but no one is replying with a solution... Im sure there must be other companies out there needing company name in the orders... It would make life so much easier to look down the orders list and look for Blah Blah Ltd rather than clicking on each random name hoping to find the order for Blah Blah ltd... Edited August 6, 2012 by Yzzy (see edit history) 1 Link to comment Share on other sites More sharing options...
Yzzy Posted August 7, 2012 Author Share Posted August 7, 2012 Anyone? I know I can probably find this out myself with a lot of digging about but someone surely must be reading this thinking how easy it is... please share!! Link to comment Share on other sites More sharing options...
Yzzy Posted August 8, 2012 Author Share Posted August 8, 2012 Sheesh.. not even a Presta Mod to say "sorry we don't know"... nice... Link to comment Share on other sites More sharing options...
fishordog Posted August 19, 2012 Share Posted August 19, 2012 (edited) $this->_select = ' ad.`company` AS `company`, a.id_order AS id_pdf, ... LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`) adding this duplicated my orders in orders tab Edited August 20, 2012 by SeVi (see edit history) Link to comment Share on other sites More sharing options...
Yzzy Posted August 20, 2012 Author Share Posted August 20, 2012 Thank you Sevi. I'll have a fiddle around with the code a bit later and see if I can get it to collect the needed info from the DB... Link to comment Share on other sites More sharing options...
fishordog Posted August 20, 2012 Share Posted August 20, 2012 Let me know if you find fix for duplicated orders with that script. For now i only managed to add the column and of course it doesnt show anything. BTW i'm trying to display country, not company, so i can see what country is order goes to w/o clicking on each order Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 22, 2012 Share Posted August 22, 2012 Try this (bold fonts are changed/added). AdminOrders.php: $this->_select = ' a.id_order AS id_pdf, ad.`company` 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, (SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (a.`id_address_delivery` = ad.`id_address`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)($cookie->id_lang).')'; $this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)'; Link to comment Share on other sites More sharing options...
fishordog Posted August 23, 2012 Share Posted August 23, 2012 (edited) I have changed and company column is still empty a.id_order AS id_pdf, ad.`company` 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, (SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (a.`id_address_delivery` = ad.`id_address`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)($cookie->id_lang).')'; $this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)'; Edited August 23, 2012 by SeVi (see edit history) Link to comment Share on other sites More sharing options...
fishordog Posted August 23, 2012 Share Posted August 23, 2012 (edited) and here is 2nd part, where i added the column $statesArray = array(); $states = OrderState::getOrderStates((int)($cookie->id_lang)); foreach ($states AS $state) $statesArray[$state['id_order_state']] = $state['name']; $this->fieldsDisplay = array( 'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false), 'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true), 'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true), 'payment' => array('title' => $this->l('Payment'), 'width' => 100), 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 100), 'company' => array('title' => $this->l('Company'), 'width' => 100), 'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'), 'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false)); parent::__construct(); Edited August 23, 2012 by SeVi (see edit history) Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 23, 2012 Share Posted August 23, 2012 It was for replacing customer column. It will show only the company name. You should change only the two lines of original file. I will look adding separate company column later. Link to comment Share on other sites More sharing options...
fishordog Posted August 23, 2012 Share Posted August 23, 2012 It was for replacing customer column. It will show only the company name. You should change only the two lines of original file. I will look adding separate company column later. thanks i was actually looking for a way to show Country, not a Company. I think i could find a way to do it once i know how to make it show the company Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 24, 2012 Share Posted August 24, 2012 This has everything: country, company, customer SQL part: $this->_select = ' a.id_order AS id_pdf, co.`iso_code` AS `country`, ad.`company` AS `company`, 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, (SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number'; $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `'._DB_PREFIX_.'order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = oh.`id_order_state`) LEFT JOIN `'._DB_PREFIX_.'address` ad ON (a.`id_address_delivery` = ad.`id_address`) LEFT JOIN `'._DB_PREFIX_.'country` co ON (ad.`id_country` = co.`id_country`) LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)($cookie->id_lang).')'; $this->_where = 'AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `'._DB_PREFIX_.'order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`)'; Column part: $this->fieldsDisplay = array( 'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false), 'country' => array('title' => $this->l('Country'), 'width' => 20), 'company' => array('title' => $this->l('Company'), 'widthColumn' => 140, 'width' => 100, 'filter_key' => 'company', 'tmpTableFilter' => true), 'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 150, 'width' => 100, 'filter_key' => 'customer', 'tmpTableFilter' => true), 'total_paid' => array('title' => $this->l('Total'), 'width' => 50, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true), 'payment' => array('title' => $this->l('Payment'), 'width' => 50), 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 120, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 120), 'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'), 'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false)); Link to comment Share on other sites More sharing options...
fishordog Posted August 24, 2012 Share Posted August 24, 2012 (edited) have tried and it does show country and company columns but they are empy and if i use filter i get :Unknown column 'company' in 'where clause' SELECT SQL_CALC_FOUND_ROWS * FROM (SELECT a.*, a.id_order AS id_pdf, CONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) AS `customer`, osl.`name` AS `osname`, os.`color`, 1 AS products, IF((SELECT COUNT(so.id_order) FROM `ps_orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new, (SELECT COUNT(od.`id_order`) FROM `ps_order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number FROM `ps_orders` a LEFT JOIN `ps_customer` c ON (c.`id_customer` = a.`id_customer`) LEFT JOIN `ps_order_history` oh ON (oh.`id_order` = a.`id_order`) LEFT JOIN `ps_order_state` os ON (os.`id_order_state` = oh.`id_order_state`) LEFT JOIN `ps_order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = 1) WHERE 1 AND oh.`id_order_history` = (SELECT MAX(`id_order_history`) FROM `ps_order_history` moh WHERE moh.`id_order` = a.`id_order` GROUP BY moh.`id_order`) HAVING product_number ORDER BY `date_add` DESC) tmpTable WHERE 1 AND `company` LIKE '%un%' LIMIT 0,50 Edited August 24, 2012 by SeVi (see edit history) Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 24, 2012 Share Posted August 24, 2012 It is working for me in version 1.4.8. You should write them exactly what I wrote, nothing more or less. Change only lines written in bold font from the original(comes from default downloding) prestashop/admin/tabs/AdminOrders.php file. Link to comment Share on other sites More sharing options...
fishordog Posted August 24, 2012 Share Posted August 24, 2012 can it be because i have 1.4.6.2 ? Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 24, 2012 Share Posted August 24, 2012 I checked ver1.4.3 AdminOrders.php file and ver 1.4.8's but couldn't find any important differences, it should work. Link to comment Share on other sites More sharing options...
Yzzy Posted August 24, 2012 Author Share Posted August 24, 2012 I'm getting Bad SQL query Link to comment Share on other sites More sharing options...
EK-Si POS Posted August 24, 2012 Share Posted August 24, 2012 This is the file that I used: http://ek-si.net/acik/AdminOrders.php.zip This is the screenshot: http://ek-si.net/acik/country-company.png Link to comment Share on other sites More sharing options...
fishordog Posted August 24, 2012 Share Posted August 24, 2012 i've tried 2 times and it displays the columns(country and company) but they're empty , so i placed a test order and both columns were empty again Link to comment Share on other sites More sharing options...
ecentury Posted October 25, 2012 Share Posted October 25, 2012 (edited) Hello, was having trouble with this also This was the cause 'company', 'tmpTableFilter' => true - so have excluded it. But i have it working now with the following code (this is for prestashop 1.5) Brings back the company in the admin orders and can search etc SQL part: $this->_select = ' a.id_currency, ad.`company` AS `company`, a.id_order AS id_pdf, 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'; $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_.'address` ad ON (a.`id_address_delivery` = ad.`id_address`) 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.')'; Column part: $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 ), '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'), ) ), 'orderby' => false ), 'customer' => array( 'title' => $this->l('Customer'), 'havingFilter' => true, 'widthColumn' => 140, 'width' => 100, ), 'company' => array( 'title' => $this->l('Company'), 'havingFilter' => true, 'widthColumn' => 140, 'width' => 100, ), 'total_paid_tax_incl' => array( 'title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'type' => 'price', 'currency' => true ), 'payment' => array( 'title' => $this->l('Payment'), 'width' => 100 ), 'osname' => array( 'title' => $this->l('Status'), 'color' => 'color', 'width' => 280, 'type' => 'select', 'list' => $statuses_array, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int' ), 'date_add' => array( 'title' => $this->l('Date'), 'width' => 130, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add' ), 'id_pdf' => array( 'title' => $this->l('PDF'), 'width' => 35, 'align' => 'center', 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false, 'remove_onclick' => true) ); Edited October 25, 2012 by ecentury (see edit history) Link to comment Share on other sites More sharing options...
wilsonj Posted April 1, 2014 Share Posted April 1, 2014 Hi, can anyone tell me how to make this work in 1.5.6.1 ? And how exactly to implement the above??? Cheers Jamie Link to comment Share on other sites More sharing options...
stnadmin Posted April 14, 2014 Share Posted April 14, 2014 (edited) The column management for order list should be a configurable thing. Where do you go to suggest good ideas? Because if I'm not mistaken all of the changes that will need to be made to get the columns to display will be lost on an update or Prestashop. Edited April 14, 2014 by stnadmin (see edit history) Link to comment Share on other sites More sharing options...
dsf Posted December 12, 2014 Share Posted December 12, 2014 Hi. Can anyone help me add a 'Company' column in the Orders page of the Back Office of version 1.6.0.9? The shop/admin/tabs/ folder is empty (no AdminOrders.php) Under shop/controllers/admin/ there is a AdminOrdersController.php file - is this what needs editing in version 1.6.0.9? Thanks for any help - it is greatly appreciated! Link to comment Share on other sites More sharing options...
dsf Posted December 13, 2014 Share Posted December 13, 2014 I hope this helps others trying to show the Company in the orders or cutomer pages in the back office of prestashop 1.6.0.9... In shop/controllers/admin/AdminOrdersController.php and shop/controllers/admin/AdminCustomersController.php there is the following bit of code to show the Company name if using B2B mode: if (Configuration::get('PS_B2B_ENABLE')) { $this->fields_list = array_merge($this->fields_list, array( 'company' => array( 'title' => $this->l('Company') ), )); } By changing it to the following, the Company column is displayed anyway: $this->fields_list = array_merge($this->fields_list, array( 'company' => array( 'title' => $this->l('Company') ), )); This should probably be done in an override but I'm not sure how to do that. Link to comment Share on other sites More sharing options...
SahinSOLMAZ Posted July 16, 2015 Share Posted July 16, 2015 I hope this helps others trying to show the Company in the orders or cutomer pages in the back office of prestashop 1.6.0.9... In shop/controllers/admin/AdminOrdersController.php and shop/controllers/admin/AdminCustomersController.php there is the following bit of code to show the Company name if using B2B mode: if (Configuration::get('PS_B2B_ENABLE')) { $this->fields_list = array_merge($this->fields_list, array( 'company' => array( 'title' => $this->l('Company') ), )); } By changing it to the following, the Company column is displayed anyway: $this->fields_list = array_merge($this->fields_list, array( 'company' => array( 'title' => $this->l('Company') ), )); This should probably be done in an override but I'm not sure how to do that. Hello, You don't need it. B.O -> Preferences -> Customer Settings -> Enable B2B Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now