public ActionResult BulkEditSelect(DataSourceRequest command, BulkEditListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); int vendorId = 0; //a vendor should have access only to his products if (_workContext.CurrentVendor != null) vendorId = _workContext.CurrentVendor.Id; var products = _productService.SearchProducts(categoryIds: new List<int> { model.SearchCategoryId}, manufacturerId: model.SearchManufacturerId, vendorId: vendorId, productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null, keywords: model.SearchProductName, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var gridModel = new DataSourceResult(); gridModel.Data = products.Select(x => { var productModel = new BulkEditProductModel { Id = x.Id, Name = x.Name, Sku = x.Sku, OldPrice = x.OldPrice, Price = x.Price, ManageInventoryMethod = x.ManageInventoryMethod.GetLocalizedEnum(_localizationService, _workContext.WorkingLanguage.Id), StockQuantity = x.StockQuantity, Published = x.Published }; if (x.ManageInventoryMethod == ManageInventoryMethod.ManageStock && x.UseMultipleWarehouses) { //multi-warehouse supported //TODO localize productModel.ManageInventoryMethod += " (multi-warehouse)"; } return productModel; }); gridModel.Total = products.TotalCount; return Json(gridModel); }
public ActionResult BulkEditSelect(DataSourceRequest command, BulkEditListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); int vendorId = 0; //a vendor should have access only to his products if (_workContext.CurrentVendor != null) vendorId = _workContext.CurrentVendor.Id; var products = _productService.SearchProducts(categoryIds: new List<int>() { model.SearchCategoryId}, manufacturerId: model.SearchManufacturerId, vendorId: vendorId, productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null, keywords: model.SearchProductName, pageIndex: command.Page - 1, pageSize: command.PageSize, showHidden: true); var gridModel = new DataSourceResult(); gridModel.Data = products.Select(x => { var productModel = new BulkEditProductModel() { Id = x.Id, Name = x.Name, AdminComment = x.AdminComment, FirstCost = x.FirstCost, CurrencyId = x.FirstCostCurrencyTypeId, DesiredProfit = x.DesiredProfit, Price = x.Price, DollarPrice = x.DollarPrice, ManageInventoryMethod = x.ManageInventoryMethod.GetLocalizedEnum(_localizationService, _workContext.WorkingLanguage.Id), StockQuantity = x.StockQuantity, Published = x.Published }; return productModel; }); gridModel.Total = products.TotalCount; return Json(gridModel); }