Close

Problem with Nop Ajax Cart

webproject
7 years ago
#13890 Quote
Avatar
  • 16
Hi all,
i have a e-commerce with nopcommerce 3.80 and bought Nop Pavilion Responsive Theme.
If i enable Nop Ajax Cart and add a product to cart, the server return
the following error:

Server Error in '/' Application.

Method not found: 'Void Nop.Web.Controllers.ShoppingCartController..ctor(Nop.Services.Catalog.IProductService, Nop.Core.IStoreContext, Nop.Core.IWorkContext, Nop.Services.Orders.IShoppingCartService, Nop.Services.Media.IPictureService, Nop.Services.Localization.ILocalizationService, Nop.Services.Catalog.IProductAttributeService, Nop.Services.Catalog.IProductAttributeFormatter, Nop.Services.Catalog.IProductAttributeParser, Nop.Services.Tax.ITaxService, Nop.Services.Directory.ICurrencyService, Nop.Services.Catalog.IPriceCalculationService, Nop.Services.Catalog.IPriceFormatter, Nop.Services.Orders.ICheckoutAttributeParser, Nop.Services.Orders.ICheckoutAttributeFormatter, Nop.Services.Orders.IOrderProcessingService, Nop.Services.Discounts.IDiscountService, Nop.Services.Customers.ICustomerService, Nop.Services.Orders.IGiftCardService, Nop.Services.Directory.ICountryService, Nop.Services.Directory.IStateProvinceService, Nop.Services.Shipping.IShippingService, Nop.Services.Orders.IOrderTotalCalculationService, Nop.Services.Orders.ICheckoutAttributeService, Nop.Services.Payments.IPaymentService, Nop.Services.Messages.IWorkflowMessageService, Nop.Services.Security.IPermissionService, Nop.Services.Media.IDownloadService, Nop.Core.Caching.ICacheManager, Nop.Core.IWebHelper, Nop.Services.Logging.ICustomerActivityService, Nop.Services.Common.IGenericAttributeService, Nop.Services.Common.IAddressAttributeFormatter, System.Web.HttpContextBase, Nop.Core.Domain.Media.MediaSettings, Nop.Core.Domain.Orders.ShoppingCartSettings, Nop.Core.Domain.Catalog.CatalogSettings, Nop.Core.Domain.Orders.OrderSettings, Nop.Core.Domain.Shipping.ShippingSettings, Nop.Core.Domain.Tax.TaxSettings, Nop.Web.Framework.Security.Captcha.CaptchaSettings, Nop.Core.Domain.Common.AddressSettings, Nop.Core.Domain.Customers.RewardPointsSettings, Nop.Core.Domain.Customers.CustomerSettings)'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.MissingMethodException: Method not found: 'Void Nop.Web.Controllers.ShoppingCartController..ctor(Nop.Services.Catalog.IProductService, Nop.Core.IStoreContext, Nop.Core.IWorkContext, Nop.Services.Orders.IShoppingCartService, Nop.Services.Media.IPictureService, Nop.Services.Localization.ILocalizationService, Nop.Services.Catalog.IProductAttributeService, Nop.Services.Catalog.IProductAttributeFormatter, Nop.Services.Catalog.IProductAttributeParser, Nop.Services.Tax.ITaxService, Nop.Services.Directory.ICurrencyService, Nop.Services.Catalog.IPriceCalculationService, Nop.Services.Catalog.IPriceFormatter, Nop.Services.Orders.ICheckoutAttributeParser, Nop.Services.Orders.ICheckoutAttributeFormatter, Nop.Services.Orders.IOrderProcessingService, Nop.Services.Discounts.IDiscountService, Nop.Services.Customers.ICustomerService, Nop.Services.Orders.IGiftCardService, Nop.Services.Directory.ICountryService, Nop.Services.Directory.IStateProvinceService, Nop.Services.Shipping.IShippingService, Nop.Services.Orders.IOrderTotalCalculationService, Nop.Services.Orders.ICheckoutAttributeService, Nop.Services.Payments.IPaymentService, Nop.Services.Messages.IWorkflowMessageService, Nop.Services.Security.IPermissionService, Nop.Services.Media.IDownloadService, Nop.Core.Caching.ICacheManager, Nop.Core.IWebHelper, Nop.Services.Logging.ICustomerActivityService, Nop.Services.Common.IGenericAttributeService, Nop.Services.Common.IAddressAttributeFormatter, System.Web.HttpContextBase, Nop.Core.Domain.Media.MediaSettings, Nop.Core.Domain.Orders.ShoppingCartSettings, Nop.Core.Domain.Catalog.CatalogSettings, Nop.Core.Domain.Orders.OrderSettings, Nop.Core.Domain.Shipping.Shi
SDobrev
7 years ago
#13892 Quote
Avatar
  • 283
Hi,

Have you made any custom modifications? Most probably the ShoppingCartController constructor is changed.

If this is the case you will have to revert your changes and use property injection instead of constructor injection.
Best Regards,
Stoyan Dobrev
Nop-Templates.com
webproject
7 years ago
#13897 Quote
Avatar
  • 16
Hi,
thank you for reply. Yes i changed the ShoppingCartController constructor.
I add

...
IAddressAttributeParser addressAttributeParser,
IAddressAttributeService addressAttributeService,
...

because i need custom address attributes not formattated, in shopping cart.

Please, explain me how use use property injection instead of constructor injection

Best regards
Giampiero
SDobrev
7 years ago
#13900 Quote
Avatar
  • 283
Hi Giampiero,

Here is an example:

private IMyService _myService;

public IMyService MyService
{
    get
    {
        if (_myService == null)
        {
            _myService = EngineContext.Current.Resolve<IMyService>();
        }

        return _myService;
    }
}
Best Regards,
Stoyan Dobrev
Nop-Templates.com
webproject
7 years ago
#13908 Quote
Avatar
  • 16
Thank you,
i remove the lines in the costructor, an add

        public IAddressAttributeParser AddressAttributeParser
        {
            get
            {
                if (_addressAttributeParser == null)
                {
                    _addressAttributeParser = EngineContext.Current.Resolve<IAddressAttributeParser>();
                }

                return _addressAttributeParser;
            }
        }

        public IAddressAttributeService AddressAttributeService
        {
            get
            {
                if (_addressAttributeService == null)
                {
                    _addressAttributeService = EngineContext.Current.Resolve<IAddressAttributeService>();
                }

                return _addressAttributeService;
            }
        }

and now the problem has been solved
rinku
3 years ago
#21680 Quote
Avatar
  • 1
Hii
I have Replaced the dependency injection  According to  you  still i'm having the below issue while going to add item to cart

Failed to load resource: the server responded with a status of 500 ()
:4439/AddProductFromProductDetailsPageToCartAjax


Any help would be highly appriciated!!!!.