Skip to content

Commit ddbb105

Browse files
committed
#1673 Warning on adding associated product which is gift card or downloadable one
1 parent fb93c02 commit ddbb105

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

src/Presentation/Nop.Web/Administration/Controllers/ProductController.cs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,17 +4353,33 @@ public ActionResult AssociateProductToAttributeValuePopup(string productIdInput,
43534353
return View(model);
43544354
}
43554355

4356-
//action displaying notification (warning) to a store owner that associated product has attributes
4356+
//action displaying notification (warning) to a store owner when associating some product
43574357
[ValidateInput(false)]
4358-
public ActionResult AssociatedProductHasAttributes(int productId)
4358+
public ActionResult AssociatedProductGetWarnings(int productId)
43594359
{
43604360
var associatedProduct = _productService.GetProductById(productId);
4361-
if (associatedProduct != null && associatedProduct.ProductAttributeMappings.Any())
4361+
if (associatedProduct != null)
43624362
{
4363-
if (associatedProduct.ProductAttributeMappings.Any(attribute => attribute.IsRequired))
4364-
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasRequiredAttributes") }, JsonRequestBehavior.AllowGet);
4363+
//attributes
4364+
if (associatedProduct.ProductAttributeMappings.Any())
4365+
{
4366+
if (associatedProduct.ProductAttributeMappings.Any(attribute => attribute.IsRequired))
4367+
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasRequiredAttributes") }, JsonRequestBehavior.AllowGet);
43654368

4366-
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes") }, JsonRequestBehavior.AllowGet);
4369+
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes") }, JsonRequestBehavior.AllowGet);
4370+
}
4371+
4372+
//gift card
4373+
if (associatedProduct.IsGiftCard)
4374+
{
4375+
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard") }, JsonRequestBehavior.AllowGet);
4376+
}
4377+
4378+
//downloaable product
4379+
if (associatedProduct.IsDownload)
4380+
{
4381+
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable") }, JsonRequestBehavior.AllowGet);
4382+
}
43674383
}
43684384

43694385
return Json(new { Result = string.Empty }, JsonRequestBehavior.AllowGet);

src/Presentation/Nop.Web/Administration/Views/Product/_CreateOrUpdateProductAttributeValue.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@
8787
<script type="text/javascript">
8888
$(document).ready(function () {
8989
if (@Model.AssociatedProductId > 0) {
90-
warningValidation('@Url.Action("AssociatedProductHasAttributes", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: '@Model.AssociatedProductId' });
90+
warningValidation('@Url.Action("AssociatedProductGetWarnings", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: '@Model.AssociatedProductId' });
9191
}
9292
9393
$('#@Html.FieldIdFor(model => model.AssociatedProductId)').on('change', function () {
94-
warningValidation('@Url.Action("AssociatedProductHasAttributes", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: $(this).val() });
94+
warningValidation('@Url.Action("AssociatedProductGetWarnings", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: $(this).val() });
9595
});
9696
});
9797
</script>

src/Presentation/Nop.Web/App_Data/Localization/defaultResources.nopres.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3465,6 +3465,12 @@
34653465
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Choose">
34663466
<Value>Choose an associated product</Value>
34673467
</LocaleResource>
3468+
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable">
3469+
<Value>The associated product is downoadable, keep in mind that won't be able to download it.</Value>
3470+
</LocaleResource>
3471+
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard">
3472+
<Value>The associated product is a gift card, keep in mind that customers can not specify its details in the product details page.</Value>
3473+
</LocaleResource>
34683474
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes">
34693475
<Value>The associated product has attributes, keep in mind that customers can not select them in the product details page.</Value>
34703476
</LocaleResource>

upgradescripts/3.80-the next version/upgrade.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,12 @@ set @resources='
11121112
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasRequiredAttributes">
11131113
<Value>The associated product has required product attributes, so customers won''t be able to choose this product attribute value.</Value>
11141114
</LocaleResource>
1115+
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable">
1116+
<Value>The associated product is downoadable, keep in mind that won''t be able to download it.</Value>
1117+
</LocaleResource>
1118+
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard">
1119+
<Value>The associated product is a gift card, keep in mind that customers can not specify its details in the product details page.</Value>
1120+
</LocaleResource>
11151121
</Language>
11161122
'
11171123

0 commit comments

Comments
 (0)