diff --git a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributeCombinations.cshtml b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributeCombinations.cshtml index 66278289c..869dc3ec0 100644 --- a/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributeCombinations.cshtml +++ b/src/Web/Grand.Web.Admin/Areas/Admin/Views/Product/_CreateOrUpdate.ProductAttributes.TabAttributeCombinations.cshtml @@ -55,23 +55,48 @@ }, dataSource: { transport: { - read: { - url: "@Html.Raw(Url.Action("ProductAttributeCombinationList", "Product", new { productId = Model.Id, area = Constants.AreaAdmin }))", - type: "POST", - dataType: "json", - data: addAntiForgeryToken + read: function(options) { + $.ajax({ + url: "@Html.Raw(Url.Action("ProductAttributeCombinationList", "Product", new { productId = Model.Id, area = Constants.AreaAdmin }))", + type: "POST", + dataType: "json", + data: addAntiForgeryToken(options.data), + success: function(result) { + options.success(result); + $('input[name="Ticks"]').val(result.ExtraData.ProductTicks); + }, + error: function(result) { + options.error(result); + } + }); }, - update: { - url: "@Html.Raw(Url.Action("ProductAttributeCombinationUpdate", "Product", new { area = Constants.AreaAdmin }))", - type: "POST", - dataType: "json", - data: addAntiForgeryToken + update: function(options) { + $.ajax({ + url: "@Html.Raw(Url.Action("ProductAttributeCombinationUpdate", "Product", new { area = Constants.AreaAdmin }))", + type: "POST", + dataType: "json", + data: addAntiForgeryToken(options.data), + success: function(result) { + options.success(result); + }, + error: function(result) { + options.error(result); + } + }); }, - destroy: { - url: "@Html.Raw(Url.Action("ProductAttributeCombinationDelete", "Product", new { area = Constants.AreaAdmin }))", - type: "POST", - dataType: "json", - data: addAntiForgeryToken + destroy: function(options) { + $.ajax({ + url: "@Html.Raw(Url.Action("ProductAttributeCombinationDelete", "Product", new { area = Constants.AreaAdmin }))", + type: "POST", + dataType: "json", + data: addAntiForgeryToken(options.data), + success: function(result) { + options.success(result); + }, + error: function(result) { + options.error(result); + } + }); } }, schema: { @@ -95,7 +120,7 @@ } }, requestEnd: function(e) { - if (e.type == "update") { + if (e.type == "update" || e.type == "destroy") { this.read(); } }, diff --git a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs index 4cb677459..76b60663e 100644 --- a/src/Web/Grand.Web.Admin/Controllers/ProductController.cs +++ b/src/Web/Grand.Web.Admin/Controllers/ProductController.cs @@ -2344,7 +2344,8 @@ public async Task ProductAttributeCombinationList(DataSourceReque var combinationsModel = await _productViewModelService.PrepareProductAttributeCombinationModel(product); var gridModel = new DataSourceResult { Data = combinationsModel, - Total = combinationsModel.Count + Total = combinationsModel.Count, + ExtraData = new { ProductTicks = product.UpdatedOnUtc.Ticks.ToString() } }; return Json(gridModel); } @@ -2372,7 +2373,7 @@ public async Task ProductAttributeCombinationDelete(string id, st await productAttributeService.DeleteProductAttributeCombination(combination, productId); if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes) { - var pr = await _productService.GetProductById(productId); + var pr = await _productService.GetProductById(productId, true); pr.StockQuantity = pr.ProductAttributeCombinations.Sum(x => x.StockQuantity); pr.ReservedQuantity = pr.ProductAttributeCombinations.Sum(x => x.ReservedQuantity); await _inventoryManageService.UpdateStockProduct(pr, false); diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs index 538393512..a8491a64e 100644 --- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs +++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs @@ -2545,7 +2545,7 @@ async Task PrepareCombinationWarehouseInventory(ProductAttributeCombination comb if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes) { - var pr = await _productService.GetProductById(model.ProductId); + var pr = await _productService.GetProductById(model.ProductId, true); pr.StockQuantity = pr.ProductAttributeCombinations.Sum(x => x.StockQuantity); pr.ReservedQuantity = pr.ProductAttributeCombinations.Sum(x => x.ReservedQuantity); await _inventoryManageService.UpdateStockProduct(pr, false);