public ActionResult BulkEdit() { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts)) return AccessDeniedView(); var model = new BulkEditListModel(); //categories model.AvailableCategories.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); var categories = _categoryService.GetAllCategories(showHidden: true); foreach (var c in categories) model.AvailableCategories.Add(new SelectListItem { Text = c.GetFormattedBreadCrumb(categories), Value = c.Id.ToString() }); //manufacturers model.AvailableManufacturers.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); foreach (var m in _manufacturerService.GetAllManufacturers(showHidden: true)) model.AvailableManufacturers.Add(new SelectListItem { Text = m.Name, Value = m.Id.ToString() }); //product types model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(false).ToList(); model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _localizationService.GetResource("Admin.Common.All"), Value = "0" }); return View(model); }
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); }