From 32287ffa604989211a7d8ed5df899481bc5607ac Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Thu, 10 Jul 2025 13:31:16 +0300 Subject: [PATCH 1/3] Post-ProductInfo Processing Hook --- ...uctInfoOnAfterProcessResponseSubscriber.cs | 29 ++++++++++++ .../Notifications/ProductInfo.cs | 45 +++++++++++++++++++ .../Products/ProductManager.cs | 3 ++ 3 files changed, 77 insertions(+) create mode 100644 src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs new file mode 100644 index 0000000..60514ce --- /dev/null +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs @@ -0,0 +1,29 @@ +using Dynamicweb.Extensibility.Notifications; +using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications; + +namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.Notifications +{ + /// + /// Class ProductInfoOnAfterProcessResponseSubscriber. + /// + /// + [Subscribe(ProductInfo.OnAfterGenerateProductInfoXml)] + public class ProductInfoOnAfterProcessResponseSubscriber : NotificationSubscriber + { + /// + /// Call to invoke observer. + /// + /// The notification. + /// The args. + public override void OnNotify(string notification, NotificationArgs args) + { + var myArgs = (ProductInfo.OnAfterProductInfoProcessResponseArgs)args; + + // TODO: Add code here + if (myArgs?.ProductInfo != null) + { + + } + } + } +} diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Notifications/ProductInfo.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Notifications/ProductInfo.cs index b6c3a43..0feb1d1 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Notifications/ProductInfo.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Notifications/ProductInfo.cs @@ -32,6 +32,11 @@ public static class ProductInfo /// public const string OnAfterGenerateProductInfoXml = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterGenerateProductInfoXml"; + /// + /// Occurs after the response from ERP is returned before the product info object is stored. This enables you to change or analyze the product info object before it's added to cache. + /// + public const string OnAfterProductInfoProcessResponse = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterProductInfoProcessResponse"; + private static List GetProductSelectionsFromProducts(Dictionary products) { var productSelections = new List(); @@ -168,5 +173,45 @@ public OnAfterGenerateProductInfoXmlArgs(List products, P /// public Logger Logger { get; } } + + /// + /// Arguments class for the OnAfterProductInfoProcessResponse subscriber. + /// + /// + public class OnAfterProductInfoProcessResponseArgs : NotificationArgs + { + /// + /// Initializes a new instance of the class. + /// + public OnAfterProductInfoProcessResponseArgs(Products.ProductInfo productInfo, XmlDocument responseXml, Settings liveIntegrationSettings, Logger logger) + { + ProductInfo = productInfo; + ResponseXml = responseXml; + Settings = liveIntegrationSettings; + Logger = logger; + } + + /// + /// Gets the product info object. + /// + /// The products. + public Products.ProductInfo ProductInfo { get; } + + /// + /// Gets the response XML document. + /// + /// The XML document. + public XmlDocument ResponseXml { get; } + + /// + /// Settings + /// + public Settings Settings { get; } + + /// + /// Logger + /// + public Logger Logger { get; } + } } } \ No newline at end of file diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/ProductManager.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/ProductManager.cs index 8286d38..d01d8f1 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/ProductManager.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Products/ProductManager.cs @@ -449,6 +449,9 @@ private static Dictionary ProcessResponse(Settings settings productInfo["ProductDefaultUnitId"] = item.SelectSingleNode("column [@columnName='ProductDefaultUnitId']")?.InnerText; } + Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(Notifications.ProductInfo.OnAfterProductInfoProcessResponse, + new Notifications.ProductInfo.OnAfterProductInfoProcessResponseArgs(productInfo, response, settings, logger)); + // avoid exception to duplicate products in XML infos.TryAdd(productIdentifier, productInfo); } From 0d1b1d7b2ed68b1918aa3299c9ea0a0193518f9a Mon Sep 17 00:00:00 2001 From: Dmitriy Benyuk Date: Thu, 10 Jul 2025 13:50:14 +0300 Subject: [PATCH 2/3] fix code --- .../ProductInfoOnAfterProcessResponseSubscriber.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs index 60514ce..1c1d58f 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples/Notifications/ProductInfoOnAfterProcessResponseSubscriber.cs @@ -7,7 +7,7 @@ namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.Notifications /// Class ProductInfoOnAfterProcessResponseSubscriber. /// /// - [Subscribe(ProductInfo.OnAfterGenerateProductInfoXml)] + [Subscribe(ProductInfo.OnAfterProductInfoProcessResponse)] public class ProductInfoOnAfterProcessResponseSubscriber : NotificationSubscriber { /// From efbffdf01ebe46b9cc7eeaba3dc12d4a9c8ab5d5 Mon Sep 17 00:00:00 2001 From: frederik5480 Date: Fri, 18 Jul 2025 09:25:42 +0200 Subject: [PATCH 3/3] Update Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj --- .../Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj index 6888e21..6865eda 100644 --- a/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj +++ b/src/Dynamicweb.Ecommerce.DynamicwebLiveIntegration/Dynamicweb.Ecommerce.DynamicwebLiveIntegration.csproj @@ -1,6 +1,6 @@  - 10.4.27 + 10.4.28 1.0.0.0 Live Integration Live Integration