4.10 ResolveUnregistered too many times (LoadAllShippingRateComputationMethods)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 anos atrás
My custom plugin logs information in the constructor, and I noticed that the system log had 4 messages when I go to the Shopping Cart Page.  I notice this in when debugging in Visual Studio, and also when running a no-source version via dotnet.exe.

1) there seems to be excessive calls to GetFixedRate / LoadAllShippingRateComputationMethods.
I've noticed the same problem even when using Shipping.FixedByWeightByTotal.  I set a break point the FixedByWeightByTotal constructor:

First call - the full trace is below, but here I show just the "callers".
Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool includingTax) Line 989  C#
  Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart) Line 978  C#
  Nop.Web.Factories.ShoppingCartModelFactory.PrepareOrderTotalsModel(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool isEditable) Line 1089  C#
  Nop.Web.dll!Nop.Web.Components.OrderTotalsViewComponent.Invoke(bool isEditable) Line 33  C#

...Views_Shared_Components_OrderSummary


Second call   
Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, out decimal discountAmount, out System.Collections.Generic.List<Nop.Services.Discounts.DiscountForCaching> appliedDiscounts, out System.Collections.Generic.List<Nop.Services.Orders.AppliedGiftCard> appliedGiftCards, out int redeemedRewardPoints, out decimal redeemedRewardPointsAmount, bool? useRewardPoints, bool usePaymentMethodAdditionalFee) Line 1264  C#
  Nop.Web.Factories.ShoppingCartModelFactory.PrepareOrderTotalsModel(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool isEditable) Line 1155  C#


Third call

...GetShoppingCartShippingTotal
...
Nop.Web.Framework.Controllers.BaseController.RenderViewComponentToString(string componentName, object arguments) Line 90  C#
Nop.Web.Controllers.ShoppingCartController.CheckoutAttributeChange(Microsoft.AspNetCore.Http.IFormCollection form, bool isEditable) Line 1098  C#


Forth Call also comes from CheckoutAttributeChange

Similarly, if I set a break point in the GetFixedRate method, it will get hit 4 times when I go to the public shopping cart page.


2) I think the above should somehow be optimized (cache the shipping info??), but what's worse is that the shipping plugins keep having to be resolved.  (I did not check to see if this also happens for other plugins).

Here's the First call full trace - note the ResolveUnregistered.  The resolving happens again every time LoadAllShippingRateComputationMethods is called.

>  Nop.Plugin.Shipping.FixedByWeightByTotal.dll!Nop.Plugin.Shipping.FixedByWeightByTotal.FixedByWeightByTotalComputationMethod.FixedByWeightByTotalComputationMethod(Nop.Plugin.Shipping.FixedByWeightByTotal.FixedByWeightByTotalSettings fixedByWeightByTotalSettings, Nop.Services.Localization.ILocalizationService localizationService, Nop.Services.Catalog.IPriceCalculationService priceCalculationService, Nop.Services.Configuration.ISettingService settingService, Nop.Plugin.Shipping.FixedByWeightByTotal.Services.IShippingByWeightByTotalService shippingByWeightByTotalService, Nop.Services.Shipping.IShippingService shippingService, Nop.Core.IStoreContext storeContext, Nop.Core.IWebHelper webHelper, Nop.Plugin.Shipping.FixedByWeightByTotal.Data.ShippingByWeightByTotalObjectContext objectContext) Line 47  C#
  [External Code]  
  Nop.Core.dll!Nop.Core.Infrastructure.NopEngine.ResolveUnregistered(System.Type type) Line 283  C#
  Nop.Core.dll!Nop.Core.Plugins.PluginDescriptor.Instance<Nop.Services.Shipping.IShippingRateComputationMethod>() Line 65  C#
  Nop.Services.dll!Nop.Services.Plugins.PluginFinder.GetPlugins.AnonymousMethod__10_0(Nop.Core.Plugins.PluginDescriptor p) Line 157  C#
  [External Code]  
  Nop.Services.dll!Nop.Services.Shipping.ShippingService.LoadAllShippingRateComputationMethods(Nop.Core.Domain.Customers.Customer customer, int storeId) Line 163  C#
  Nop.Services.dll!Nop.Services.Shipping.ShippingService.LoadActiveShippingRateComputationMethods(Nop.Core.Domain.Customers.Customer customer, int storeId) Line 139  C#
  Nop.Services.dll!Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool includingTax, out decimal taxRate, out System.Collections.Generic.List<Nop.Services.Discounts.DiscountForCaching> appliedDiscounts) Line 1043  C#
  Nop.Services.dll!Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool includingTax, out decimal taxRate) Line 1002  C#
  Nop.Services.dll!Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool includingTax) Line 989  C#
  Nop.Services.dll!Nop.Services.Orders.OrderTotalCalculationService.GetShoppingCartShippingTotal(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart) Line 978  C#
  Nop.Web.dll!Nop.Web.Factories.ShoppingCartModelFactory.PrepareOrderTotalsModel(System.Collections.Generic.IList<Nop.Core.Domain.Orders.ShoppingCartItem> cart, bool isEditable) Line 1089  C#
5 anos atrás
Thanks! We'll check it - https://github.com/nopSolutions/nopCommerce/issues/3231
5 anos atrás
Is this related to using the Shipping director?
5 anos atrás
glhays wrote:
Is this related to using the Shipping director?

This was initially noticed while testing Shipping director, but as per above, it was reproduced using Shipping.FixedByWeightByTotal
5 anos atrás
Done. Please see this commit for more details.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.