Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Dynamicweb.Extensibility.Notifications;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications;

namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples.Notifications
{
/// <summary>
/// Class ProductInfoOnAfterProcessResponseSubscriber.
/// </summary>
/// <seealso cref="NotificationSubscriber" />
[Subscribe(ProductInfo.OnAfterProductInfoProcessResponse)]
public class ProductInfoOnAfterProcessResponseSubscriber : NotificationSubscriber
{
/// <summary>
/// Call to invoke observer.
/// </summary>
/// <param name="notification">The notification.</param>
/// <param name="args">The args.</param>
public override void OnNotify(string notification, NotificationArgs args)
{
var myArgs = (ProductInfo.OnAfterProductInfoProcessResponseArgs)args;

// TODO: Add code here
if (myArgs?.ProductInfo != null)
{

}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>10.4.27</Version>
<Version>10.4.28</Version>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<Title>Live Integration</Title>
<Description>Live Integration</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public static class ProductInfo
/// </example>
public const string OnAfterGenerateProductInfoXml = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterGenerateProductInfoXml";

/// <summary>
/// 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.
/// </summary>
public const string OnAfterProductInfoProcessResponse = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterProductInfoProcessResponse";

private static List<PriceProductSelection> GetProductSelectionsFromProducts(Dictionary<Product, double> products)
{
var productSelections = new List<PriceProductSelection>();
Expand Down Expand Up @@ -168,5 +173,45 @@ public OnAfterGenerateProductInfoXmlArgs(List<PriceProductSelection> products, P
/// </summary>
public Logger Logger { get; }
}

/// <summary>
/// Arguments class for the OnAfterProductInfoProcessResponse subscriber.
/// </summary>
/// <seealso cref="NotificationArgs" />
public class OnAfterProductInfoProcessResponseArgs : NotificationArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="OnAfterProductInfoProcessResponseArgs"/> class.
/// </summary>
public OnAfterProductInfoProcessResponseArgs(Products.ProductInfo productInfo, XmlDocument responseXml, Settings liveIntegrationSettings, Logger logger)
{
ProductInfo = productInfo;
ResponseXml = responseXml;
Settings = liveIntegrationSettings;
Logger = logger;
}

/// <summary>
/// Gets the product info object.
/// </summary>
/// <value>The products.</value>
public Products.ProductInfo ProductInfo { get; }

/// <summary>
/// Gets the response XML document.
/// </summary>
/// <value>The XML document.</value>
public XmlDocument ResponseXml { get; }

/// <summary>
/// Settings
/// </summary>
public Settings Settings { get; }

/// <summary>
/// Logger
/// </summary>
public Logger Logger { get; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ private static Dictionary<string, ProductInfo> 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);
}
Expand Down
Loading