Sorting Invoice Order Items

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
abradley
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 101
Joined: Wed Feb 12, 2014 4:46 pm

Sorting Invoice Order Items

Post by abradley » Tue Dec 09, 2014 6:26 am

We pick all our orders by the invoices and we are tired of running all around the store since it does not sort the items in a useful way.

We would like to have the invoice to sort the items first by manufacturer, then by sku.

I am pretty sure I need to edit the OrderItemComparer.cs but I have no idea where to begin. Anyone got some advice on accomplishing this?

Thanks, Austin
Austin

abradley
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 101
Joined: Wed Feb 12, 2014 4:46 pm

Re: Sorting Invoice Order Items

Post by abradley » Tue Dec 09, 2014 6:29 am

And for that matter, a way to do this outside the source code would be much better.
Austin

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Sorting Invoice Order Items

Post by david-ebt » Mon Dec 15, 2014 1:30 pm

Austin,

If you have the source, you can make a copy of the OrderItemComparer.cs file and put it into your App_Code folder. Give it a new name and change the name of the class to something unique like MyOrderItemComparer. Then you can use that class in the ViewOrder.aspx.cs to use your sort instead of the standard one.

To do the actual sort, you'll set up the multiple compare levels like the standard OrderItemComparer code does inside your new MyOrderItemComparer class.

Hopefully that will set you on the right track.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

abradley
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 101
Joined: Wed Feb 12, 2014 4:46 pm

Re: Sorting Invoice Order Items

Post by abradley » Wed Jan 21, 2015 12:36 pm

Thank you David! I was able to accomplish my goal and get items sorted as I like.

All my invoices are properly sorting now, except for when they are multi-page invoices. If the list of items spans more than one page, no sort occurs.
Austin

abradley
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 101
Joined: Wed Feb 12, 2014 4:46 pm

Re: Sorting Invoice Order Items

Post by abradley » Mon Jan 26, 2015 10:37 am

I have applied two sorts in GetItems() on the Print/Invoice.aspx.cs

Code: Select all

items.Sort(new OrderItemComparer()); // Original Sort by Able
items.Sort("Name");
items.Sort("OrderItemTypeId");
The sorts work properly on most orders except for when a order spans 2 or more pages. Then the invoice prints non-sorted.

I just debugged the page, and the method is being called and both sorts do occur before the OrderItems collection is passed to the GridView and bound. I cant find where things break yet.
Austin

abradley
Lieutenant Commander (LCDR)
Lieutenant Commander (LCDR)
Posts: 101
Joined: Wed Feb 12, 2014 4:46 pm

Re: Sorting Invoice Order Items

Post by abradley » Thu Feb 05, 2015 12:50 pm

Any ideas on what would make a sort break upon a multiple page order?
Austin

Post Reply