Copied to clipboard

Flag this post as spam?

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


  • Peter Rombouts 71 posts 265 karma points
    Nov 14, 2013 @ 13:21
    Peter Rombouts
    0

    Using Tea Commerce: Stock Management in C#

    Hi all,

    I'm trying to save the new stock values in my C# class library; We have a synchronization with back-end stock management software.

    Saving the property using the default Umbraco way (getProperty etc.) does not persist the value.

    Is there an API call to raise stock levels?
    The only call I can find is 'GetStock' but obviously that is only for getting the value, not setting the value

    Kind regards,
    Peter Rombouts

  • Anders Burla 2560 posts 8256 karma points
    Nov 14, 2013 @ 14:29
    Anders Burla
    0

    You should use the ProductService.SetStock in the .NET API

    Kind regards
    Anders

  • Peter Rombouts 71 posts 265 karma points
    Nov 14, 2013 @ 17:02
    Peter Rombouts
    0

    Hi Anders,

    Thanks for your reply, but I'm getting the following error:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at TeaCommerce.Umbraco.Configuration.Persistence.DatabaseFactory.Get()
       at TeaCommerce.Api.Persistence.Repositories.ProductRepository.SetStock(Int64 storeId, String sku, Nullable`1 value)
       at TeaCommerce.Api.Services.ProductService.SetStock(Int64 storeId, String sku, Nullable`1 value)
       at TennisToday.CustomCode.pages.UpdateStock.RunUpdateStock()

    The SKU is valid, and I've added the productSKU property to the TeaCommerce settings.
    Any ideas?

    Kind regards,
    Peter Rombouts

  • Anders Burla 2560 posts 8256 karma points
    Nov 15, 2013 @ 08:28
    Anders Burla
    0

    Ahh are you running this completely outside of Umbraco? Because Umbraco sets up the database connection and some autofac code. So that is why it properly doesn't work. So if you can add it into your Umbraco project and run it in that context that would be good. Else I need to find a way in TC to say - TC.Umbraco.Setup and then things happens :)

  • Peter Rombouts 71 posts 265 karma points
    Nov 15, 2013 @ 08:40
    Peter Rombouts
    0

    Hi Anders,

    I'm running an ASPX page which we call in a Umbraco ScheduleTask (put in an assembly, basic routine)
    I've got the context of Umbraco:

    var cs = ApplicationContext.Current.Services.ContentService;

    I can lookup and save/edit nodes, so my context works and Umbraco is up and running.

    Any ideas?

    Kind regards,
    Peter Rombouts

  • Anders Burla 2560 posts 8256 karma points
    Nov 15, 2013 @ 08:45
    Anders Burla
    0

    Tea Commerce use the ApplicationBase class of Umbraco to hook stuff up when Umbraco starts. BUT I think that with Umbraco 6 API they changed things so you can get the Umbraco context without the Umbraco application starting. Else try and check your log file in App_Data and see if Tea Commerce has logged anything.

    Kind regards
    Anders

  • Peter Rombouts 71 posts 265 karma points
    Nov 15, 2013 @ 08:57
    Peter Rombouts
    100

    Hi Anders,

    I've found the problem. My code was running in the background, and that loses the TC context

    ThreadPool.QueueUserWorkItem(s => RunUpdateStock());

    Running the method in foreground fixes the issue.

    Thanks for looking at my problem, and I hope someone has use for this info!

    Kind regards.
    Peter Rombouts

Please Sign in or register to post replies

Write your reply to:

Draft