Invoice products sort order
ZC 1.5.8
I need to sort the items order by manufacturer. I know people will say orders are picked with the packing slip, but these orders contain OTC medical items, so the packing slip is sparce due to PMI requirements and they pick with the invoice.
I have tried a bunch of things and can't get this going in 1.5.8.
Any help is appreciated =)
~Melanie
Re: Invoice products sort order
Look at includes/classes/order.php line 285. That's the product select for the products in the order. You want to join orders_products with products on the products_id field so you can get products.manufacturers_id, and order on that.
Re: Invoice products sort order
Quote:
Originally Posted by
swguy
Look at includes/classes/order.php line 285. That's the product select for the products in the order. You want to join orders_products with products on the products_id field so you can get products.manufacturers_id, and order on that.
Yep, I tried that but the following doesn't work
Code:
$this->billing['zone_id'] = $this->getCountryZoneId((int)$this->billing['country'], $this->billing['state']);
//Melanie sort orders by manufacturer
$index = 0;
$orders_products_query = "SELECT *
FROM " . TABLE_ORDERS_PRODUCTS . "
WHERE orders_id = " . (int)$this->orderId . "
ORDER BY products_manufacturers ASC";
$orders_products = $db->Execute($orders_products_query);
while (!$orders_products->EOF) {
// convert quantity to proper decimals - account history
Re: Invoice products sort order
Quote:
Originally Posted by
swguy
Look at includes/classes/order.php line 285. That's the product select for the products in the order. You want to join orders_products with products on the products_id field so you can get products.manufacturers_id, and order on that.
... or, without modifying a core file, check out the NOTIFY_ORDER_AFTER_QUERY notification, through which you can modify the sort/display order of the products in the order after the order's information has been gathered.
That notification is issued on (zc158a) the /includes/classes/order.php module's line 375.
Re: Invoice products sort order
> Yep, I tried that but the following doesn't work
You didn't try that. Reread what I wrote.
a) join orders_products with products on the products_id field
b) [order by] products.manufacturers_id
You are attempting to order by products_manufacturers, which doesn't exist in the default schema.
If you created it and added it to the orders_products table, you likely not populating it at order creation time.
Re: Invoice products sort order
Quote:
Originally Posted by
lat9
... or, without modifying a core file, check out the NOTIFY_ORDER_AFTER_QUERY notification, through which you can modify the sort/display order of the products in the order after the order's information has been gathered.
That notification is issued on (zc158a) the /includes/classes/order.php module's line 375.
i suppose this is a good way to do it. one would need to ensure that the script being called is the invoice script, else all uses of the order when queried will now be sorted this way.
the other alternative is to the use the NOTIFY_ADMIN_INVOICE_SORT_DISPLAY notifier. it looks like you need to return an array with all of the original array element numbers in the sorted order. a little confusing, but i think i see how that would work.
best.
Re: Invoice products sort order
Quote:
Originally Posted by
carlwhat
i suppose this is a good way to do it. one would need to ensure that the script being called is the invoice script, else all uses of the order when queried will now be sorted this way.
the other alternative is to the use the NOTIFY_ADMIN_INVOICE_SORT_DISPLAY notifier. it looks like you need to return an array with all of the original array element numbers in the sorted order. a little confusing, but i think i see how that would work.
best.
Don't have to use an "either/or" notifier situation. A single observer class listens for the invoice notifier, noting that condition and then as the associated order notifier is triggered while the invoice was hit, then obviously in the invoice loop reading from the orders....
Notifiers are not 100% to be used all alone. There is a flow of operation, data made available and points at which additional operations should be performed.
Re: Invoice products sort order
mc, i can only assume your comment is for the good of the community as opposed to me specifically. i have used indicators in the past to process code based on hitting multiple notifiers within a single observer class. it can be pretty slick and powerful. a plug-in i did for edit orders uses that strategy to great effect.
unfortunately that will not work in this case. the order object gets created prior to the invoice notifier.
best.
Re: Invoice products sort order
Hopefully @mprough you have enough to go on based on this thread.
Yet another option would be to create a new admin utility, based on some hybrid of packing slip and invoice, that created exactly what you needed for the pick-and-pack crew (without whatever you don't need). Lots of possibilities here.