diff --git a/Nop.Plugin.Misc.AIPlugin/Components/ProductAttributesViewComponent.cs b/Nop.Plugin.Misc.AIPlugin/Components/ProductAttributesViewComponent.cs index 2373507..0c9d974 100644 --- a/Nop.Plugin.Misc.AIPlugin/Components/ProductAttributesViewComponent.cs +++ b/Nop.Plugin.Misc.AIPlugin/Components/ProductAttributesViewComponent.cs @@ -34,12 +34,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components if (model.ProductId > 0) { - var measuringAttributeValues = await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync(model.ProductId); - if (measuringAttributeValues != null) - { - model.IsMeasurable = measuringAttributeValues.IsMeasurable; - model.NetWeight = measuringAttributeValues.NetWeight; - } + //var measuringAttributeValues = await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync(model.ProductId); + //if (measuringAttributeValues != null) + //{ + // model.IsMeasurable = measuringAttributeValues.IsMeasurable; + // model.NetWeight = measuringAttributeValues.NetWeight; + //} + + model.IsMeasurable = await _fruitBankAttributeService.GetGenericAttributeValueAsync(model.ProductId, nameof(IMeasurable.IsMeasurable)); + model.NetWeight = await _fruitBankAttributeService.GetGenericAttributeValueAsync(model.ProductId, nameof(IMeasuringNetWeight.NetWeight)); model.Tare = await _fruitBankAttributeService.GetGenericAttributeValueAsync(model.ProductId, nameof(ITare.Tare)); model.IncomingQuantity = await _fruitBankAttributeService.GetGenericAttributeValueAsync(model.ProductId, nameof(IIncomingQuantity.IncomingQuantity)); diff --git a/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs b/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs index c0e100d..72f714f 100644 --- a/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs +++ b/Nop.Plugin.Misc.AIPlugin/Domains/EventConsumers/FruitBankEventConsumer.cs @@ -19,6 +19,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Services; using Nop.Services.Common; using Nop.Services.Events; using System.Globalization; +using Mango.Nop.Core.Extensions; namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers; @@ -90,7 +91,9 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa //IsMeasurable isMeasurable = form[nameof(IMeasurable.IsMeasurable)].ToString().Contains("true"); - if (productDto == null || productDto.IsMeasurable != isMeasurable.Value) + var productDtoIsMeasurable = productDto?.GenericAttributes.GetValueOrNull(nameof(IMeasurable.IsMeasurable)); + + if (productDtoIsMeasurable == null || productDtoIsMeasurable.Value != isMeasurable.Value) { await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(product.Id, nameof(IMeasurable.IsMeasurable), isMeasurable.Value); isMeasurableChanged = true; @@ -98,7 +101,9 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAcc, FruitBa //NetWeight var netWeight = double.Round(CommonHelper.To(form[nameof(IMeasuringNetWeight.NetWeight)].ToString()), 1); - if (productDto == null || productDto.NetWeight != netWeight) + var productDtoNetWeight = productDto?.GenericAttributes.GetValueOrNull(nameof(IMeasuringNetWeight.NetWeight)); + + if (productDtoNetWeight == null || double.Round(productDtoNetWeight.Value, 1) != netWeight) await fruitBankAttributeService.InsertOrUpdateGenericAttributeAsync(product.Id, nameof(IMeasuringNetWeight.NetWeight), netWeight); //Tára