Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -95,7 +120,7 @@
}
},
requestEnd: function(e) {
if (e.type == "update") {
if (e.type == "update" || e.type == "destroy") {
this.read();
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/Web/Grand.Web.Admin/Controllers/ProductController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,8 @@ public async Task<IActionResult> 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);
}
Expand Down Expand Up @@ -2372,7 +2373,7 @@ public async Task<IActionResult> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down