Hi:
I have to implement a range price facet. This range has to contain the maximun and minimun price of a set of products.
For example , if i have a set of bikes the minimun is 100 and the maximun is 10000.
So if i want to get only the white bikes by a facet the minimun and maximun price must belong to the white bikes set.
Im trying to get this maximun and minimun using a BeforeQuery / AfterQuery but i get a StackOverFlowException in both notifications.
Here is the code of the notifications:
BeforeQueryNotification
namespace Cemevisa.Notifications { [Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Indexing.Notifications.Query.BeforeQuery)] public class BeforeQueryNotification : Dynamicweb.Extensibility.Notifications.NotificationSubscriber { public override void OnNotify(string notification, NotificationArgs args) { Dynamicweb.Indexing.Notifications.Query.BeforeQueryArgs beforeQueryArgs = args as Dynamicweb.Indexing.Notifications.Query.BeforeQueryArgs; if (args == null || !(args is Dynamicweb.Indexing.Notifications.Query.BeforeQueryArgs)) return; QueryService queryService = new QueryService(); IQueryResult queryResult = queryService.Query(beforeQueryArgs.Query, beforeQueryArgs.Settings); base.OnNotify(notification, args); } } }
AfterQueryNotification
namespace Cemevisa.Notifications { [Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Indexing.Notifications.Query.AfterQuery)] public class AfterQueryNotification : Dynamicweb.Extensibility.Notifications.NotificationSubscriber { public override void OnNotify(string notification, NotificationArgs args) { Dynamicweb.Indexing.Notifications.Query.AfterQueryArgs afterQueryArgs = args as Dynamicweb.Indexing.Notifications.Query.AfterQueryArgs; if (args == null || !(args is Dynamicweb.Indexing.Notifications.Query.AfterQueryArgs)) return; double max = 0.0, min= Double.MaxValue; //ejecutar la consulta para obtener los maximos y los minimos QueryService queryService = new QueryService(); IQueryResult queryResult = queryService.Query(afterQueryArgs.Query, afterQueryArgs.Settings); IEnumerable<object> resultado = queryService.Query(afterQueryArgs.Query, afterQueryArgs.Settings).QueryResult; resultado.Count(); if(resultado.Count() <= 1000) { foreach (var products in resultado) { //get the maximun and minimun } } base.OnNotify(notification, args); } } }
Is there another way to do this?
Jose,
Regards.