lepusa Posted June 21, 2016 Share Posted June 21, 2016 (edited) We are using PS v.1.6.1.5, and presently when the initial order confirmation is emailed to the customer, the products are listed in the same sequence that the customer added them to the order. However, the PDF Invoice (Sales Order) prints them alphabetically by name.For sake of ease for the customer, these items should be displayed in the same sequence they were added to the order. This is also true for the PDF Delivery Slip and Packing Slip. Is there a way to retain the original sequence of line items as entered by the customer? Edited June 21, 2016 by lepusa (see edit history) Link to comment Share on other sites More sharing options...
lepusa Posted September 7, 2016 Author Share Posted September 7, 2016 Bump, and ideas on this? Link to comment Share on other sites More sharing options...
rocky Posted September 8, 2016 Share Posted September 8, 2016 I checked the code and found it's sorting by name on line 147 in the OrderInvoice::getProductDetail() function: '.($this->id && $this->number ? ' AND od.`id_order_invoice` = '.(int)$this->id : '').' ORDER BY od.`product_name`'); You could try overriding this and removing the ORDER BY. For example, create override/classes/OrderInvoice.php with the following: <?php class OrderInvoice extends OrderInvoiceCore { 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.' '.($this->id && $this->number ? ' AND od.`id_order_invoice` = '.(int)$this->id : '')); } } Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. 1 Link to comment Share on other sites More sharing options...
lepusa Posted September 9, 2016 Author Share Posted September 9, 2016 I checked the code and found it's sorting by name on line 147 in the OrderInvoice::getProductDetail() function: '.($this->id && $this->number ? ' AND od.`id_order_invoice` = '.(int)$this->id : '').' ORDER BY od.`product_name`'); You could try overriding this and removing the ORDER BY. For example, create override/classes/OrderInvoice.php with the following: <?php class OrderInvoice extends OrderInvoiceCore { 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.' '.($this->id && $this->number ? ' AND od.`id_order_invoice` = '.(int)$this->id : '')); } } Remember to go to Advanced Parameters > Performance and click the "Clear cache" button (or manually delete cache/class_index.php) so PrestaShop can find the override. That did the trick, thanks! 1 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