Table of Contents

Class Ecommerce.Querying

Namespace
Dynamicweb.Ecommerce.Notifications
Assembly
Dynamicweb.Ecommerce.dll

Class Querying. This class cannot be inherited.

public sealed class Ecommerce.Querying
Inheritance
Ecommerce.Querying
Inherited Members

Fields

AfterQuery

The after query

public const string AfterQuery = "DWN_QUERYING_AfterQuery"

Field Value

string

BeforeQuery

The before query

public const string BeforeQuery = "DWN_QUERYING_BeforeQuery"

Field Value

string

BeforeQueryDatabase

Before query database notification

public const string BeforeQueryDatabase = "DWN_QUERYING_BeforeQueryDatabase"

Field Value

string

Examples

using System;

namespace Dynamicweb.Ecommerce.Examples.Notifications
{
	/// <summary>
	/// Subscribing on Cart.Created event
	/// </summary>
	[Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Ecommerce.Notifications.Ecommerce.Querying.BeforeQueryDatabase)]
	public class BeforeQueryDatabaseObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
	{
		/// <summary>
		/// This notification is thrown every time an index based search has been done
		/// </summary>
		/// <param name="notification"></param>
		/// <param name="args"></param>
		public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
		{
			if (args == null || !(args is Dynamicweb.Ecommerce.Notifications.Ecommerce.Querying.BeforeQueryDatabaseArgs))
				return;
			var cArgs = (Dynamicweb.Ecommerce.Notifications.Ecommerce.Querying.BeforeQueryDatabaseArgs)args;

			var autoids = new System.Collections.Generic.List<Int64>();

			using (var myDr = Dynamicweb.Data.Database.CreateDataReader($"SELECT ProductAutoID FROM EcomProducts WHERE ProductAutoID in ({cArgs.AutoIds.ToString()}) ORDER BY ProductNumber"))
			{
				while (myDr.Read())
				{
					autoids.Add(Dynamicweb.Core.Converter.ToInt64(myDr["ProductAutoID"]));
				}
			}

			cArgs.AutoIds = autoids;


		}
	}
}

Remarks

Use this to change the search results after the index query has been done or to change the sorting of the results. The args contains a list of autoids (AutoIds) that can be used to search further. Return the autoids in the order they should be sorted.

To top