Dear Dynamicweb,
We have a site with a lot of products and when a group is saved then the site hangs for several seconds as we a missing some logic to check whether url dependent properties are changed. Please take a look a the existing code here from ShopUrlDataProvider:
[Subscribe(Notifications.Ecommerce.Group.AfterSave)]
[Subscribe(Notifications.Ecommerce.Group.Deleted)]
public class GroupChangedObserver : NotificationSubscriber
{
public override void OnNotify(string notification, NotificationArgs args)
{
UrlHelper.SetResetNeeded();
}
}
And compared to the logic for changing products which are actually doing this:
[Subscribe(Notifications.Ecommerce.Product.AfterSave)]
[Subscribe(Notifications.Ecommerce.Product.AfterDelete)]
public class ProductChangedObserver : NotificationSubscriber
{
public override void OnNotify(string notification, NotificationArgs args)
{
var changeAffectUrlIndex = false;
if (args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Product.AfterSaveArgs)
{
var saveArgs = args as Notifications.Ecommerce.Product.AfterSaveArgs;
var beforeSaveProduct = saveArgs.ProductBeforeChanges;
var afterSaveProduct = saveArgs.Product;
if (beforeSaveProduct != null)
{
changeAffectUrlIndex |= !beforeSaveProduct.Id.Equals(afterSaveProduct.Id);
changeAffectUrlIndex |= !beforeSaveProduct.VariantId.Equals(afterSaveProduct.VariantId);
changeAffectUrlIndex |= !beforeSaveProduct.LanguageId.Equals(afterSaveProduct.LanguageId);
changeAffectUrlIndex |= !beforeSaveProduct.Name.Equals(afterSaveProduct.Name);
changeAffectUrlIndex |= !beforeSaveProduct.Meta.Url.Equals(afterSaveProduct.Meta.Url);
}
else
{
changeAffectUrlIndex = true;
}
}
if (changeAffectUrlIndex)
{
lazyProductUrlDataIndex = new Lazy<ConcurrentDictionary<string, Dictionary<string, UrlDataNode>>>(InitializeProductUrlDataIndex);
UrlHelper.SetResetNeeded();
}
}
}
Hope you will look into this.
Best regards, Anders