MinnaLaa Posted October 16, 2018 Share Posted October 16, 2018 (edited) Hello Because of the physical storage system I need delivery slip or/and invoice to have sort order by product's reference. These documents are going to be printed out and products are collected from the storage in certain order. So, either or of these documents need to have sort ordered by product's reference number (green high lighted part of the image). Is there any solution to this? I have access to code. Edited October 17, 2018 by MinnaLaa (see edit history) Link to comment Share on other sites More sharing options...
MinnaLaa Posted October 17, 2018 Author Share Posted October 17, 2018 PS 1.7.3. Found a solution for this... classes/order/OrderInvoice.php somewhere around row 130 where getProductsDetail change ' ORDER BY od.`product_name`'); to ' ORDER BY od.`product_reference`'); 4 Link to comment Share on other sites More sharing options...
gorkij77 Posted July 31, 2019 Share Posted July 31, 2019 Thank you. This should properly be a setting in the back office! Link to comment Share on other sites More sharing options...
Sucreglass Posted January 8, 2022 Share Posted January 8, 2022 @MinnaLaa Created an account just to thank you for sharing this so slick solution! 1 Link to comment Share on other sites More sharing options...
ecentury Posted September 28, 2022 Share Posted September 28, 2022 Thanks for solution Just to add if you want the delivery slip / invoice in exact same product order as you can see in the backend then change line 139 (in above file location) ' . ($this->id && $this->number ? ' AND od.`id_order_invoice` = ' . (int) $this->id : '') . ' ORDER BY od.`product_name`'); to ' . ($this->id && $this->number ? ' AND od.`id_order_invoice` = ' . (int) $this->id : '') . ' ORDER BY od.`id_order_detail` DESC'); Best to create an override Link to comment Share on other sites More sharing options...
gorkij77 Posted September 28, 2022 Share Posted September 28, 2022 41 minutes ago, ecentury said: Thanks for solution Just to add if you want the delivery slip / invoice in exact same product order as you can see in the backend then change line 139 (in above file location) ' . ($this->id && $this->number ? ' AND od.`id_order_invoice` = ' . (int) $this->id : '') . ' ORDER BY od.`product_name`'); to ' . ($this->id && $this->number ? ' AND od.`id_order_invoice` = ' . (int) $this->id : '') . ' ORDER BY od.`id_order_detail` DESC'); Best to create an override Thank you for this, extra info is good. How do you create an override? Link to comment Share on other sites More sharing options...
legacy12 Posted November 24, 2022 Share Posted November 24, 2022 Quick question I managed to add the short description on the delivery slip. We also want to sort the product using the data in the short description. This is done in /classes/order/OrderInvoice.php with the following code: 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 : '') . ' ORDER BY od.`product_reference`'); } The short description information is located in ps_product_lang database. Does someone know how to change the query above? Thanks! 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