Posted on 09/06/2021 15:25:19
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));
}
}
}