Copied to clipboard

Flag this post as spam?

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


  • Ole Abrahamsen 12 posts 52 karma points
    Jun 11, 2013 @ 13:38
    Ole Abrahamsen
    0

    Adding an orderline from c#

    Hello, I'm trying to script an order creation (trying to migrate from TC1.4.4.4 to TC2.x), but when I try to get a product from the database, the object returned is null (well, a new empty orderline, not exactly null):

     

    Guid g = new Guid("EABA0C27-6636-44E7-84D2-77B94DABAA29");
    long l = 1;
    
    Order order = TC.GetOrder(l, g);
    
    var ps = new ProductSnapshot(1, "1249");
    var ol = new OrderLine(ps);
    order.OrderLines.Add(ol)
    
    order.Save();

    Both the ProductSnapshot and the OrderLine has no value, other than the values I provide:

    Image 2013-06-11 at 1.36.52 PM.png

    How do I add an orderline? :)

    Best regards,
    Ole Abrahamsen

  • Rune Grønkjær 1371 posts 3102 karma points
    Jun 11, 2013 @ 14:07
    Rune Grønkjær
    0

    Are you trying to create a new order? In that case just try to create a new order object and save it:

    Order order = new Order( 1 );
          order.Save();

    /Rune

  • Ole Abrahamsen 12 posts 52 karma points
    Jun 11, 2013 @ 14:12
    Ole Abrahamsen
    0

    I already did create a new order - I'm actually retrieving that order and trying to add an orderline.

  • Anders Burla 2560 posts 8256 karma points
    Jun 11, 2013 @ 14:23
    Anders Burla
    0

    Hi Ole

    What context are you in? A web request? A console application or?

    Kind regards
    Anders

  • Ole Abrahamsen 12 posts 52 karma points
    Jun 11, 2013 @ 14:35
    Ole Abrahamsen
    0

    Hello Anders

    The application is a web forms application, so the context is a web request. :)

    Best regards,
    Ole Abrahamsen

  • Anders Burla 2560 posts 8256 karma points
    Jun 11, 2013 @ 17:14
    Anders Burla
    0

    And the web application is a dll that is then copied and run in the context of the Umbraco site? Could you try and describe your case a little more?

    And by the way - why not just use the order.OrderLines.AddOrUpdate( string productIdentifier)? The productIdentifier is just your umbraco node id.

    Kind regards
    Anders

  • Ole Abrahamsen 12 posts 52 karma points
    Jun 12, 2013 @ 09:40
    Ole Abrahamsen
    0

    Sorry - I'm new to this.

    The web application is using the Umbraco dlls, with the umbracoDbDSN configured in the web.config.

    It is just a web forms application with the dlls attached. I can retrieve(or create) any order without problems, however, when trying to add a line to an order, stuff happens.

    I'm pretty sure it is a configuration issue, but I can't wrap my head around it. When trying to use the "order.OrderLines.AddOrUpdate, I get a strange error:

    Image 2013-06-12 at 9.30.32 AM.png 

  • Anders Burla 2560 posts 8256 karma points
    Jun 17, 2013 @ 11:22
    Anders Burla
    0

    When you add an order line with the product identifier 1249 this means the Umbraco node with the id 1249. So this node or an ancestor does need a store associated with it using the store picker in the Umbraco admin.

    Kind regards
    Anders

Please Sign in or register to post replies

Write your reply to:

Draft