Developer forum

Forum » Ecommerce - Standard features » Intercept product search

Intercept product search

Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Hi,

I'm working on a solution on DW 8.9.2.6, where I need to intercept the product search.
If an empty resultset is returned, I need to redirect the customer to another page.

The default "noresult" page is not an option, as the customer wants DW to search in other product groups, if no result is found in the current group.

I've tried making a NotificationSubscriber, by subscribing to Dynamicweb.eCommerce.Querying.AfterQuery, but it doesn't get fired at all. I've also tried subscribing to Dynamicweb.eCommerce.ProductList.BeforeRender and checking for an empty products object, but this doens't work either.

Any suggestions on how to do this?

--
Best regards
Kurt Moskjaer Andersen


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Kurt,

 

For a project a while back we did a "poor man's work" to develop all of the additional logic in the "No results" template. So we would additially search for something sumiting additional query string parameters (which would trigger additional query expressions in the Repository).

 

It's not perfect, as it triggered a redirect which was visible to the customer, but we made use of it by displaying a message like "No results so far... expanding your search!".

 

But I am sure somebody else will jump is and suggest the proper way to do it :)

 

Best Regards,

Nuno Aguiar

 
Nicolai Pedersen
Reply

Hi Kurt

In DW8 there are at least 4 different searhes for products. ecomQuery, weighted search, Repositories, and the old Lucene implementation.

So first question is which one you happen to use? Next Q is what you want to achieve in the no results page - whats should happen?

BR Nicolai

 
Nicolai Pedersen
Reply

If you just need a redirect, simply do it with javascript in the "Nothing found" part of your template.

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Would a Server.Transfer work server-side when you detect there aren't any results?

Imar

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

It is the old-fashioned ecomQuery that is used, by giving the query in the querystring.

If no result is found, I need to search in other groups as well, and if a result is found, redirect to that page.

/Kurt

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Or mayby it is the old Lucene index. It's a site we've got from another partner.

How do I see what kind of search is used?

/Kurt

 
Nicolai Pedersen
Reply

How does the search look like? The URL and the setup of the paragraph with the catalog module?

 
Kurt Moskjær Andersen
Kurt Moskjær Andersen
Reply

Det er vist ecomQuery, kombineret med filter :)

/Kurt

 

searchform.jpg

 

You must be logged in to post in the forum