public ActionResult BestsellersReportList(GridCommand command, BestsellersReportModel model) { DateTime? startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime? endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; //return first 100 records //group by product variants (not products) var items = _orderReportService.BestSellersReport(startDateValue, endDateValue, orderStatus, paymentStatus, null, model.BillingCountryId, 100, 2, 1, true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var m = new BestsellersReportLineModel() { ProductVariantId = x.EntityId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var productVariant = _productService.GetProductVariantById(x.EntityId); if (productVariant != null) m.ProductVariantFullName = productVariant.Product.Name + " " + productVariant.Name; return m; }), Total = items.Count }; return new JsonResult { Data = gridModel }; }
public ActionResult BestsellersReportList(GridCommand command, BestsellersReportModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) return Content(""); //a vendor should have access only to his products int vendorId = 0; if (_workContext.CurrentVendor != null) vendorId = _workContext.CurrentVendor.Id; DateTime? startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime? endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; var items = _orderReportService.BestSellersReport( createdFromUtc: startDateValue, createdToUtc: endDateValue, os: orderStatus, ps: paymentStatus, billingCountryId: model.BillingCountryId, orderBy: 2, vendorId: vendorId, categoryId: model.CategoryId, manufacturerId: model.ManufacturerId, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var m = new BestsellersReportLineModel() { ProductId = x.ProductId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var product = _productService.GetProductById(x.ProductId); if (product!= null) m.ProductName = product.Name; return m; }), Total = items.TotalCount }; return new JsonResult { Data = gridModel }; }
protected IList<BestsellersReportLineModel> GetBestsellersBriefReportModel(int recordsToReturn, int orderBy) { //group by product variants (not products) var report = _orderReportService.BestSellersReport(null, null, null, null, null, 0, recordsToReturn, orderBy, 1, true); var model = report.Select(x => { var m = new BestsellersReportLineModel() { ProductVariantId = x.EntityId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var productVariant = _productService.GetProductVariantById(x.EntityId); if (productVariant != null) m.ProductVariantFullName = productVariant.Product.Name + " " + productVariant.Name; return m; }).ToList(); return model; }
protected GridModel<BestsellersReportLineModel> GetBestsellersBriefReportModel(int pageIndex, int pageSize, int orderBy) { //a vendor should have access only to his products int vendorId = 0; if (_workContext.CurrentVendor != null) vendorId = _workContext.CurrentVendor.Id; var items = _orderReportService.BestSellersReport( vendorId : vendorId, orderBy: orderBy, pageIndex: pageIndex, pageSize: pageSize, showHidden: true); var gridModel = new GridModel<BestsellersReportLineModel> { Data = items.Select(x => { var m = new BestsellersReportLineModel() { ProductId = x.ProductId, TotalAmount = _priceFormatter.FormatPrice(x.TotalAmount, true, false), TotalQuantity = x.TotalQuantity, }; var product = _productService.GetProductById(x.ProductId); if (product != null) m.ProductName = product.Name; return m; }), Total = items.TotalCount }; return gridModel; }