Developer forum

Forum » Integration » Find out if Live Integration is active

Find out if Live Integration is active

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I am building a custom price provider that runs on a site that can also have standard Live integration enabled. How do I go about testing if LI is enabled? I wanted to do what the LI subscribers do like this:

protected static bool EnabledAndActive(Settings settings)
{
  var cacheValue = Context.Current?.Items?["DynamicwebLiveIntegrationEnabledAndActive"];
  if (cacheValue != null)
  {
    return (bool)cacheValue;
  }
  var result = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration.Global.IsIntegrationActive(settings)
                && Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Connectors.Connector.IsWebServiceConnectionAvailable(settings);
  if (Context.Current?.Items != null)
  {
    Context.Current.Items["DynamicwebLiveIntegrationEnabledAndActive"] = result;
  }
  return result;
}

However, Global and Connector are internal so I can't use them. Is there another way I can determine if LI is enabled?

Also, price providers don't seem to honor a Rank or other sorting attribute. Is there a way to order them by priority so I can determine if my provider runs before or after the standard one? 

Thanks!

Imar


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

We implemented the same thing, but had to built a custom version of Live Integration and had to use the Connector at the time. I understand you are trying to just use some notifications.

In case it helps and/or eventually make this a standard feature, this is how our end result looks. It's a (custom) webapi endpoint, we can then use some monitoring tools (not in DW) to request and parse the response, notifying the customer or ourselves (rather than being reactive and waiting for issues).

 

We're happy to share the code, if that's helpful.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

 I actually want something different. It's not in a subscriber but in another price provider. I want to implement something like this:

public override FindPrice(...)
{
  if (LiveIntegration.IsEnabled(context.Shop)
  {
    return null; // Back off for this Shop
  }
  var price = new DefaultPriceProvider().FindPrice(...);
  return price * 1.2;
}

So, when LI is already active for this site, don't do anything. Otherwise, do something custom with the price.

Price Providers are chained (called in a loop until one returns a price) but the order is not guaranteed so I need to make sure that when LI is enabled, my code is doing nothing, otherwise it must add the markup.

Imar

 

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Imar,
you can get the Active Live settings by shop using this method:
var settings = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration.SettingsManager.GetSettingsByShop(shopId);
If (settings != null)
means that the settings are active/enabled.
BR, Dmitrij

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Thanks Dmitrij!

 

You must be logged in to post in the forum