Skip to content

Commit

Permalink
#1673 Warning on adding associated product which is gift card or down…
Browse files Browse the repository at this point in the history
…loadable one
  • Loading branch information
AndreiMaz committed Dec 26, 2016
1 parent fb93c02 commit ddbb105
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4353,17 +4353,33 @@ public ActionResult AssociateProductToAttributeValuePopup(string productIdInput,
return View(model);
}

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

return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes") }, JsonRequestBehavior.AllowGet);
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes") }, JsonRequestBehavior.AllowGet);
}

//gift card
if (associatedProduct.IsGiftCard)
{
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard") }, JsonRequestBehavior.AllowGet);
}

//downloaable product
if (associatedProduct.IsDownload)
{
return Json(new { Result = _localizationService.GetResource("Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable") }, JsonRequestBehavior.AllowGet);
}
}

return Json(new { Result = string.Empty }, JsonRequestBehavior.AllowGet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@
<script type="text/javascript">
$(document).ready(function () {
if (@Model.AssociatedProductId > 0) {
warningValidation('@Url.Action("AssociatedProductHasAttributes", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: '@Model.AssociatedProductId' });
warningValidation('@Url.Action("AssociatedProductGetWarnings", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: '@Model.AssociatedProductId' });
}
$('#@Html.FieldIdFor(model => model.AssociatedProductId)').on('change', function () {
warningValidation('@Url.Action("AssociatedProductHasAttributes", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: $(this).val() });
warningValidation('@Url.Action("AssociatedProductGetWarnings", "Product")', '@Html.FieldNameFor(model => model.AssociatedProductId)', { productId: $(this).val() });
});
});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3465,6 +3465,12 @@
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Choose">
<Value>Choose an associated product</Value>
</LocaleResource>
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable">
<Value>The associated product is downoadable, keep in mind that won't be able to download it.</Value>
</LocaleResource>
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard">
<Value>The associated product is a gift card, keep in mind that customers can not specify its details in the product details page.</Value>
</LocaleResource>
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasAttributes">
<Value>The associated product has attributes, keep in mind that customers can not select them in the product details page.</Value>
</LocaleResource>
Expand Down
6 changes: 6 additions & 0 deletions upgradescripts/3.80-the next version/upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,12 @@ set @resources='
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.HasRequiredAttributes">
<Value>The associated product has required product attributes, so customers won''t be able to choose this product attribute value.</Value>
</LocaleResource>
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.Downloadable">
<Value>The associated product is downoadable, keep in mind that won''t be able to download it.</Value>
</LocaleResource>
<LocaleResource Name="Admin.Catalog.Products.ProductAttributes.Attributes.Values.Fields.AssociatedProduct.GiftCard">
<Value>The associated product is a gift card, keep in mind that customers can not specify its details in the product details page.</Value>
</LocaleResource>
</Language>
'

Expand Down

0 comments on commit ddbb105

Please sign in to comment.