Developer forum

Forum » Development » Disable LiveIntegration in Product Queries

Disable LiveIntegration in Product Queries

Tomas Gomez
Reply

Hi,

We want to speed up some Product Queries that don't need LiveIntegration to get the fields of the products.

We avoided the ERP calls in the feed code by a custom query parameter (LivePrice=false) but the response times of the queries are same as before.

How could we disable the LiveIntegration in some queries? 

Regards,
Tomas


Replies

 
Nicolai Pedersen
Reply

Hi Tomas

On the actual page that handles the query, try to add ?debug=true - that will give you some timings and will reveal what part of the execution is slow. When that is located you can see where to look - if it is live integration or something else.

BR Nicolai

 
Tomas Gomez
Reply

Hi Nicolai,

Thanks for the tip, it confirmed that the delay is due to the LiveIntegration.

How could we disable the LiveIntegration in certain cases? For instance, in these queries.

Regards,
Tomas

 

 
Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga
Reply

If live integration is active and the user is not disabled for live pricing this call always goes to the integration.

what you can do is write your own criteria inside on live integration source ProductListBeforeSort and ProductBeforeRender classes.

this is notification subscribers call before the render in the frontend 

 
Tomas Gomez
Reply

Hi Shiwanka,

We tried your suggestion. Below is the source code of ProductListBeforeSort, as the ProductBeforeRender is not called in our case.

In the ProductListBeforeSort code, we discriminate the feed that has to avoid the live integration and then return. The live integration is still active even with this customization.

What are we doing wrong? Is there any other place we should customize?

Regards,
Tomas

[Subscribe(Ecommerce.Notifications.Ecommerce.ProductList.BeforeSort)]
    public class ProductListBeforeSort : NotificationSubscriberBase
    {
        /// <summary>
        /// Handles the notification.
        /// </summary>
        /// <param name="notification">The notification.</param>
        /// <param name="args">The args.</param>
        public override void OnNotify(string notification, NotificationArgs args)
        {
            Dynamicweb.Logging.LogManager.Current.GetLogger("ERPCalls").Log("ProductListBeforeSort");
            if (!CanCheckPrice)
            {
                return;
            }
            Dynamicweb.Logging.LogManager.Current.GetLogger("ERPCalls").Log("Entering the feed");
            var myArgs = (Ecommerce.Notifications.Ecommerce.ProductList.BeforeSortArgs)args;
            // Avoid ERP callings in feed with ID=2475
            if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ID")) && HttpContext.Current.Request.QueryString.Get("ID").Equals("2475"))
            {
                Dynamicweb.Logging.LogManager.Current.GetLogger("ERPCalls").Log("Use no ERP");
                return;
            }
            // Set product info
            if (myArgs.Products.Any())
            {
                SetProductInformation(Products.ProductManager.GetProductsWithQuantities(myArgs.Products));
            }
        }
    }

 
Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga
Reply
This post has been marked as an answer

Hi Thomas

you're doing this change outside of the Dynamicweb.Ecommerce.LiveIntegration?

open your liveintegration project source

do it in here...

Votes for this answer: 1
 
Shiwanka Chathuranga Dynamicweb Employee
Shiwanka Chathuranga
Reply
This post has been marked as an answer

I just confirm for you both notification subscribers calling correctly

 

 

Votes for this answer: 1
 
Tomas Gomez
Reply

Hi Shiwanka,

Thanks for the support, it worked! It really saves times executing some particular queries without the LiveIntegration :-)

Regards,
Tomas

 

You must be logged in to post in the forum