Hi,
When a customer in Ecom makes a product search, I would like to intercept it.
If no result is given in the current productgroup, I would like to make a search on all groups.
To achieve this, I'm trying to hook into the NotificationSubscriber, to get a notification before the productlist is rendered to the frontend.
I'm doing this with the following code:
[Subscribe(eCommerce.ProductList.BeforeRender)]
public class ProductListBeforeRenderSubscriber : NotificationSubscriber
{
/// <summary>
/// After output on page
/// </summary>
/// <param name="notification"></param>
/// <param name="args"></param>
public override void OnNotify(string notification, NotificationArgs args)
{
eCommerce.ProductList.BeforeRenderArgs BeforeQuerArgs = args as eCommerce.ProductList.BeforeRenderArgs;
if(BeforeQuerArgs != null)
{
if (BeforeQuerArgs.Products != null)
{
My problem is, that if I check the BeforeQuerArgs.Products.Count, it is always empty, even though results have been found. If I iterate through the loop with the following code, the counter is incremented as it should for each product found:
foreach (var item in BeforeQuerArgs.Products)
{
countProducts += 1;
}
Is this the wrong approach to achieve this or am I missing something?
Best regards
Kurt Moskjaer Andersen