Developer forum

Forum » Development » BeforeQuery subscriber in ProductViewModel

BeforeQuery subscriber in ProductViewModel

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We have converted some of our product lists to the new ProductViewModel (9.8), but now our subscriber: Ecommerce.Querying.BeforeQuery is not hit anymore.

 

Where should we place this?

 

Best regards, Anders


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
This post has been marked as an answer

Hi Anders,

You can use the equivalent notification from Dynamicweb.Indexing. You'll find it here: Dynamicweb.Indexing.Notifications.Query.BeforeQuery.

- Jeppe

Votes for this answer: 1
 
Johan Lang
Johan Lang
Reply

Dear DW,

We also use subscriber: Ecommerce.Querying.BeforeQuery in an old project with success, like the tread:
https://doc.dynamicweb.com/forum/development/development/productlist-notificationsubscriber

We have change the subscriber to: Dynamicweb.Indexing.Notifications.Query.BeforeQuery in a newer
project and it hit but it's not take effect when we try use code like the tread abowe: notificationArgs.Settings.Parameters.Add("MP", true);
to change parametetrs, why? 

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Johan,
I checked the issue with parameter overriding - on the first view all is fine.
Please make sure that:
1. The parameter actually is used in a query
2. The name is the same - note, case is important!
3. The type is correct - i.e. MP is Boolean, not a String.

If everything is right, send a file with a description of the query and the request code. Let's look it together.
But please create a simple example for testing purposes! :)

Best regards,
Vladimir

 

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

PS: Query definisions are stored in \Files\System\Repositories\{name of repository}

 
Johan Lang
Johan Lang
Reply

Hi Vladimir,

Yes, please reply my email and book a time when it suit you and we look at it together.

Best regards.

Johan

 

 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

No Emails please. Keep it in forum.... :-)

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

hmm... didn't yet receive a mail:(

Best regards,
Vladimir

 
Johan Lang
Johan Lang
Reply

Hi Vladimir,

Ok, does any time after 1 pm suit on monday or tuesday?

Please, let us look at it toghether then.

Nice weekend!

Best regards

Johan

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Johan - post your code here - and we will fix it here. No meetings, no mails please - otherwise you have to contact Dynamicweb Care at care@dynamicweb.com

Thank you for your understanding.

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Johan,

I'm sorry! I expressed myself wrongly and almost violated company policy! 
I meant, let I try to test, debug your example, which you will post on the forum of course :)

Best regards,
Vladimir

 
Johan Lang
Johan Lang
Reply

Ok!

Well, we try to override the standard parameter SortBy, it's added as parameter in the code below in the notification subscriber but it has no effect.
How can the standrad parameter SortBy be overrided?
 
[Subscribe(Dynamicweb.Indexing.Notifications.Query.BeforeQuery)]
public override void OnNotify(string notification, NotificationArgs args)
{
if (!(args is Dynamicweb.Indexing.Notifications.Query.BeforeQueryArgs))  return;
 
     var notificationArgs = (Dynamicweb.Indexing.Notifications.Query.BeforeQueryArgs)args;
notificationArgs.Settings.Parameters.Add("SortBy", "-Rating");
}
 
Johan Lang
Johan Lang
Reply

Hello again!

See code debug in action:

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Johan,

There is no standard parameter for SortBy, but the frontend app uses that for compatibility -- Product Catalog existed before indexing and therefore used a different way to sort. Product Catalog for ViewModels uses the same facade for consistensy's sake. Changing a parameter value and overriding the sort order are not the same thing at a query level.

Sorting is defined using the Settings.SortOrder property. To change the sort order, you must change this property. The order in which you specify the sorting is important as it affects the result.

- Jeppe

 

You must be logged in to post in the forum