Try Now
More in this section

Forums / Ecommerce / Custom Order Report - Get Product Type for each Order

Custom Order Report - Get Product Type for each Order

2 posts, 1 answered
  1. Gavin
    Gavin avatar
    6 posts
    08 Oct 2012
    31 Jul 2013
    Link to this post
    I am trying to get the Product Type of each Product within the context of a list of all Orders. I am currently binding all Orders to a RadGrid for reporting purposes. Below is a snippet which hopefully shows what I am trying to acheive:

    protected void Page_Load(object sender, EventArgs e)

                //Store Orders in "orderList" then bind it to RadGrid.
                var orderList = new List<OrderReportView>();

                OrdersManager ordersManager = OrdersManager.GetManager();
                IQueryable<Order> orders = ordersManager.GetOrders();

                foreach (Order order in orders)

                    var theOrder = new OrderReportView();

                    theOrder.OrderNumber = order.OrderNumber;
                    theOrder.OrderDate = order.OrderDate;
                    theOrder.OrderStatus = order.OrderStatus;
                    theOrder.Total = order.Total;

                    //Assume only 1 Product per Order.
                    theOrder.Title = order.Details[0].Title;
                    //NOW SOMETHING LIKE THIS BELOW??
                    theOrder.ProductType = order.Details[0].ProductTypeName; //eg. "Book"



                RadGrid1.DataSource = orderList;


    Any help would be appreciated.
  2. Patrick Dunn
    Patrick Dunn avatar
    237 posts
    03 Nov 2014
    01 Aug 2013
    Link to this post
    Hello Gavin,

     You will have to match the product clrtype to the product type clrtype. I do this in my Product model I use when I want to cut our certain data from being returned (for example in the case of custom web api or auto generated reports).

    namespace SitefinityWebApp.Data.Models
        public class ProductModel
            public Guid Id { get; set; }
            public string ProductType { get; set; }
            public string Title { get; set; }
            public ProductModel() { }
            public ProductModel(Product product)
                var em = EcommerceManager.GetManager();
                this.Id = product.Id;
                this.Title = product.Title;
                this.ProductType = em.GetProductTypes().Where(pt => pt.ClrType == product.ClrType).FirstOrDefault().Title;

    I hope this helps.

    Patrick Dunn
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 1 answered