Copied to clipboard

Flag this post as spam?

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


  • Chris Eddy 5 posts 75 karma points
    Sep 24, 2017 @ 17:53
    Chris Eddy
    0

    How to access Merchello services from outside of umbraco

    We have a customer front end built with umbraco and merchello and that works fine, but now we are trying to build a custom CRM where sales staff can access merchello customers and orders.

    I set up the project with references to Umbraco.core and Mechello.core and set up the umbraco connection string in the web.config that points to our umbraco database. Everything compiles, but when I try to access MerchelloContext I get a null reference because there is no current context.

    Here is the codebit that is failing...

            var customerService = MerchelloContext.Current.Services.CustomerService;
    
            var customers = customerService.GetPage(1, 20, "LastName").Items.ToList();
    

    From what I have read, this is occurring because the context is not being initiated in the startup of the project.

    So I wondering what else I need to do other than add references for the umbraco.core and merchello.core to make this work.

    Or is there a different API call that I can make to pull customer information outside or Umbraco.

  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Sep 29, 2017 @ 16:31
    Alex Skrypnyk
    0

    Hi Chris

    You can add custom api that will return all needed information. But it will take time and you will have full control over data.

    Thanks,

    Alex

  • Chris Eddy 5 posts 75 karma points
    Sep 30, 2017 @ 18:14
    Chris Eddy
    0

    Alex - Thanks for your reply. Do you have any details or examples about how to add a custom api?

  • Alex Skrypnyk 6148 posts 24097 karma points MVP 8x admin c-trib
    Sep 30, 2017 @ 22:16
    Alex Skrypnyk
    0

    Hi Chris,

    Try to use "Merchello.Web.WebApi.MerchelloApiController" it's the same as UmbracoApiController but with Merchello context, read more about Umbraco API:

    https://our.umbraco.org/documentation/implementation/Controllers/#umbraco-api-controllers

    https://merchello.readme.io/docs/view-pages

    Thanks,

    Alex

  • Chris Eddy 5 posts 75 karma points
    Sep 30, 2017 @ 23:25
    Chris Eddy
    0

    Thanks, Again Alex! I will give the API a look.

  • Chris Eddy 5 posts 75 karma points
    Oct 01, 2017 @ 03:36
    Chris Eddy
    0

    Hi Alex -

    No Luck. I created a web api controller and inherited from MerchelloApiController, but when I try to invoke the method, I get the same error as before, except this time it occurs when it tries to create the controller. Any other thoughts?

Please Sign in or register to post replies

Write your reply to:

Draft