Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • fabrice 104 posts 227 karma points
    Jul 14, 2010 @ 10:57
    fabrice
    0

    Adding products from external source (console app)

    Hello,

    My name is Fabrice and I'm new to Umbraco and Ucommerce.

    I have successfully installed Umbraco 4.04, the latest uCommerce and uCommerceStore and I have integrated it into Visual Studio 2010 (asp.net 3.5)

    For my project I need to add and update products to uCommerce daily from an external source (web service).

    My first idea was to create a .Net console application which will do the import and i'll schedule it daily. Is that a good way to do the job ?

    For first  test purpose I tried to add/update products to uCommerce demo store from my Console app but I have issues setting the project for the console app and calling uCommerce API.

    Here is how I did :

    I have added a reference to businesslogic.dll, cms.dll, umbraco.dll, uCommerce.dll, subsonic.core.dll to the app project and I have copy paste the content of the web.config from my Umbraco install into a new app.config for the console.

    I have added also "using UCommerce.Entities;" in the main file. There is also "using UCommerce.EntitiesV2;" but I dont know which one is the best...

    First, I just tried to call the code to add a product from http://blog.lasseeskildsen.net/post/uCommerce-How-To-Create-A-Product-Using-The-API.aspx:

    var product = new Product
                {
                    Sku = "SKU-123456",
                    Name = "My Product",
                    AllowOrdering = true,
                    DisplayOnSite = true,
                    ProductDefinitionId = 1,  // Set to an existing defintion
                    ThumbnailImageMediaId = 1 // ID from Umbraco (nullable int)
                };

    product.Save();

    but I get a NullReferenceException, Object reference not set to an instance of an object. when I call the Save method.

    I would be very gratefull if you could help me to figure out how to set up the console project and how to call the uCommerce API.

    Thank you very much,

    Fabrice

     

     

     

  • Lasse Eskildsen 34 posts 57 karma points
    Jul 14, 2010 @ 13:13
    Lasse Eskildsen
    0

    Hi Fabrice,

    You should use UCommerce.Entities for the code sample above.

    Have you verified that you have a product definition with id = 1? If you have, can you post your app.config?

    - Lasse

     

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jul 14, 2010 @ 13:57
    Søren Spelling Lund
    0

    Hi Fabrice,

    uCommerce versions prior to 1.0.4.0 were bound tightly to http context even in the data access layer. That's the null reference exception you're seeing. If you download version 1.0.4.0 you won't have that problem. Download uCommerce 1.0.0.4.0 from our site.

    Upgrading is simple. You just install the package on top of your existing installation.

  • fabrice 104 posts 227 karma points
    Jul 14, 2010 @ 13:59
    fabrice
    0

    Great, I'll update now and keep you in touch.

     

    Thank you very much !

  • Søren Spelling Lund 1797 posts 2786 karma points
    Jul 14, 2010 @ 14:01
    Søren Spelling Lund
    0

    If the answer is help please mark as the solution as it makes it much easier for us to keep track of issues we need to address. Thanks.

  • fabrice 104 posts 227 karma points
    Jul 14, 2010 @ 15:09
    fabrice
    0

    Great ! Yes it solved the problem !Thank you very much

    For info, after updated, I didnt change anything from the config that I described below (except that I used a ProductDefinitionID that exist, thanks Lasse) to make it work.

Please Sign in or register to post replies

Write your reply to:

Draft