Jump to content

(solved) 1.7.3. Delivery slip/invoice PDF product sort order by product reference, not alphabetical


Recommended Posts

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.

 

order-sort.png

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

  • 9 months later...
  • 2 years later...
  • 8 months later...

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

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

  • 1 month later...

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

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