Jump to content

I need to create a column on the orders, help me with the query


Akyla

Recommended Posts

Here is theproblem i have a code reated with each order so my problem is call it in to a new column on the orders BO I aready made the column i cant retrive the data

 

 

global $cookie;
  $this->table = 'order';
  $this->className = 'Order';
  $this->view = true;
 $this->colorOnBackground = true;
  $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`)';

 

 

 

my column is inside ps_order_details and its called `code` how can i achive to call this column into the query

 

here is one of my tries wich work once before i change states on the orders

 


(SELECT `code` FROM `ps_order_detail` odd WHERE odd.`id_order`= a.`id_order`) as codes,

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