Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

Admin - do not generate null attribute combinations

supporteff09b79e388
diff --git a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
index 5b4d03741..5adaf3ca7 100644
--- a/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
+++ b/src/Web/Grand.Web.Admin/Services/ProductViewModelService.cs
@@ -2562,10 +2562,13 @@ namespace Grand.Web.Admin.Services
if (allAttributesComb == null || allAttributesComb.Count == 0)
return;
- var id = 1;
foreach (var attributes in allAttributesComb)
{
- var existingCombination = product.FindProductAttributeCombination(attributes.ToList());
+ var customAttributes = attributes.ToList();
+ if (!customAttributes.Any())
+ continue;
+
+ var existingCombination = product.FindProductAttributeCombination(customAttributes);
//already exists?
if (existingCombination != null)
@@ -2573,7 +2576,7 @@ namespace Grand.Web.Admin.Services
//save combination
var combination = new ProductAttributeCombination {
- Attributes = attributes.ToList(),
+ Attributes = customAttributes.ToList(),
StockQuantity = 0,
AllowOutOfStockOrders = false,
Sku = null,
@@ -2583,7 +2586,6 @@ namespace Grand.Web.Admin.Services
NotifyAdminForQuantityBelow = 1,
};
await _productAttributeService.InsertProductAttributeCombination(combination, product.Id);
- id++;
}
if (product.ManageInventoryMethodId == ManageInventoryMethod.ManageStockByAttributes)