Sorting Order Items List

For general questions and discussions specific to the AbleCommerce GOLD ASP.Net shopping cart software.
Post Reply
mharoonbhatti
Ensign (ENS)
Ensign (ENS)
Posts: 1
Joined: Wed Jan 08, 2014 3:20 am

Sorting Order Items List

Post by mharoonbhatti » Wed Apr 13, 2016 8:45 am

Is there a way to sort order items based on SKU column.

Shop/admin/orders/Print/PackSlips.aspx

Code: Select all

  OrderShipment shipment = (OrderShipment)dataItem;
            Order order = shipment.Order;
            IList<OrderItem> products = new List<OrderItem>();
            foreach (OrderItem item in order.Items)
            {
                if ((item.OrderItemType == OrderItemType.Product) && (item.OrderShipmentId == shipment.Id))
                {
                    if (item.IsChildItem)
                    {
                        // WHETHER THE CHILD ITEM DISPLAYS DEPENDS ON THE ROOT
                        OrderItem rootItem = item.GetParentItem(true);
                        if (rootItem != null && rootItem.Product != null && rootItem.ItemizeChildProducts)
                        {
                            // ITEMIZED DISPLAY ENABLED, SHOW THIS CHILD ITEM
                            products.Add(item);
                        }
                    }
                    else products.Add(item);
                }
            }
            products.Sort(new OrderItemComparer());
            return products;
I have tried products.Sort("Sku",CommerceBuilder.Common.SortDirection.ASC)

but no luck.

Any help in this regard is greatly appreciated.

Thx,

AbleCommerce GOLD R11

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Sorting Order Items List

Post by mazhar » Thu Apr 14, 2016 2:12 am

You will have to replace following code

Code: Select all

products.Sort(new OrderItemComparer());
with

Code: Select all

products.Sort("Sku", CommerceBuilder.Common.SortDirection.ASC);
Also if you are using Web Application version then in order make these changes work you will need to build the website project. If you are using Website version then you just need to refresh the page and it should work.

Post Reply