nopCommerce API

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 yıl önce
saintperez wrote:
I have modified my code after reading a few posts to the following: but I'm getting the error mentioned bellow.


        public void InsertProducts()
        {
            Product OP = new Product();
            OP.Name = "Bla";
            OP.ShortDescription = "efwfewf";

            NopConfig.Init();
            IoC.InitializeWith(new DependencyResolverFactory());
            var oPSvc = IoC.Resolve<IProductService>();
            oPSvc.InsertProduct(OP);
        }


Resolution of the dependency failed, type = "NopSolutions.NopCommerce.BusinessLogic.Products.IProductService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type NopObjectContext has multiple constructors of length 1. Unable to disambiguate.
-----------------------------------------------
At the time of the exception, the container was:

  Resolving NopSolutions.NopCommerce.BusinessLogic.Products.ProductService,(none) (mapped from NopSolutions.NopCommerce.BusinessLogic.Products.IProductService, (none))
  Resolving parameter "context" of constructor NopSolutions.NopCommerce.BusinessLogic.Products.ProductService(NopSolutions.NopCommerce.BusinessLogic.Data.NopObjectContext context)
    Resolving NopSolutions.NopCommerce.BusinessLogic.Data.NopObjectContext,(none)





hopefully this helps
http://stackoverflow.com/questions/1696326/unity-passing-in-a-new-datacontext-each-time
it's not the same context of the error, but the solution they provide (top voted answer) should get you in the right direction.
13 yıl önce
hi saintperez, i never touched the resolver, don't so i have no idea what the problem is here. if you trying to build an importer i can send you my code. it was working fine last time i looked at it.
13 yıl önce
I just ran into this problem last night.

You don't need to call NopConfig.Init() .  Make sure that your app config has all of the essential nopCommerce config sections/entries, then just call IoC.Resolve<T>() for whatever you are looking to get an instance of,

i.e. orderService = IoC.Resolve<IOrderService>();
11 yıl önce
Hi,
Did anyone create a full working WCF method for inserting or updating products? I need to do this now and it seems silly to reinvent the wheel if someone already has already done the same thing :)  If you could post or PM me the code for this function I'd be very grateful.

Many thanks!
Nick
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.