Jump to content

[SOLVED]Edit PDF invoice -sort order:Reference


havegang

Recommended Posts

Try changing the getProductDetail() function in classes/Order.php from:

public function getProductsDetail()
{
   return Db::getInstance()->ExecuteS('
   SELECT *
   FROM `'._DB_PREFIX_.'order_detail` od
   WHERE od.`id_order` = '.intval($this->id));
}



to:

public function getProductsDetail()
{
   return Db::getInstance()->ExecuteS('
   SELECT *
   FROM `'._DB_PREFIX_.'order_detail` od
   WHERE od.`id_order` = '.intval($this->id).'
   ORDER BY od.`product_reference`');
}

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
  • 5 months later...
  • 2 months later...

Save this Override as /overrides/classes/order/Order.php:

 

<?php
/* override Sort by reference ID */
class Order extends OrderCore{
public function getProductsDetail()
{
 return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
 SELECT *
 FROM `'._DB_PREFIX_.'order_detail` od
 LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
 LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
 WHERE od.`id_order` = '.(int)($this->id).'
 ORDER BY od.`product_reference`');
}
}

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

  • 1 month later...
  • 3 weeks later...
  • 1 year later...

Running prestashop 1.6, editing creating an override in order.php only affected the display of the product order in the store.  To have that order changed in invoices, I needed to edit OrderInvoice.php.

 

1. Copy /classes/order/OrderInvoice.php to /overrides/classes/orderOrderInvoice.php

2. Make edit as stated initially.

 

My code ended up like this:

	public function getProductsDetail()
	{
		return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
		SELECT *
		FROM `'._DB_PREFIX_.'order_detail` od
		LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = od.product_id)
		LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (ps.id_product = p.id_product AND ps.id_shop = od.id_shop)
		WHERE od.`id_order` = '.(int)($this->id).'
		ORDER BY od.product_reference ASC');
	}
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...

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