Jump to content

[BO] Get group name in order list (near customer name)


ang3lx

Recommended Posts

Hello,

is possible to print name of groups of user into orders list

In to the order i resolved with

 

function getGroupName($id_customer, $id_lang){
  $sql = '
  SELECT gl.`name`
  FROM `'._DB_PREFIX_.'group_lang` AS gl WHERE gl.`id_group` IN ('.$id_customer.') AND gl.`id_lang` = '.intval($id_lang) . '
  ORDER BY gl.name DESC
  ';

  return Db::getInstance()->getValue($sql);
 }
$list_groups = implode(",", $customer->getGroups());
$n_gruppo = getGroupName($list_groups,intval(_USER_ID_LANG_));

and I've printed out $ngruppo var. But I can't know how can something into orders list

 

thanks in advance

 

Nello

Edited by ang3lx (see edit history)
Link to comment
Share on other sites

Hello,

 

I tried to set the group name in the order list

I changed the code from :

 

  $this->_select = '
  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,
  (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_.'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`)';

 

to this

  $this->_select = '
  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,
  (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->_select = '(
  SELECT g.`name` FROM `'._DB_PREFIX_.'group_lang` g
  LEFT JOIN `'._DB_PREFIX_.'customer_group` cg ON (cg.`id_group` = g.`id_group`)
  WHERE g.`id_group` != 1 AND g.`id_lang`=1 AND cg.`id_customer` = a.id_customer
 ) as company';		
  $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_.'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`)';

 

but only the groups appear and all the other informations are unavailable so I presume that this query should be integrated but how ?

 

PS: This code works great in the AdminCustomers.php

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