Generic fix for "Search pages return 0 results if there is an unknown query parameter"

We keeping facing the “Search pages return 0 results if there is an unknown query parameter” problem every time a new external site links to our site, most recently for Pinterest ads that add epik and pp query parameters.

Is there a known/common generic fix for this?

In the accelerator in SearchQueryMapper.SearchQueryResolver, after the blacklisted query parameters, there is some code to handle other parameters. Not sure whether this code assumes anything not blacklisted is a valid query filter. But I guess this is where a “generic” fix should go.

There is also a closed bug for this
48635 - Search pages return 0 results if there is an unknown query parameter that I don’t really understand why it’s closed.

The bug was closed since it’s implemented that way by design. You can vote for a different default implementation here: Accelerator category pages should not fail when an tracking | Ideas

Since the logic is in the Accelerator, you could implement your own validation of the query parameter. Maybe that for the default switch case, it will try and fetch a product field definition by that id and break if it doesn’t exist.

1 Like

There is a list of parameters in the accelerator that are excluded from being included as filters in the search and the simples solution is to extend that list with known parameters but a perhapps better solution is to do like Nils suggest and look if the parameter is actually a field in litium.

Look in the searchquerymapper

foreach (var key in queryString.AllKeys)
                {
                    switch (key)
                    {
                        // Google Analytics www.demo.se/?utm_source=source&utm_medium=medium&utm_term=term&utm_content=content&utm_campaign=campaignname
                        case "utm_source":
                        case "utm_medium":
                        case "utm_term":
                        case "utm_content":
                        case "utm_campaign":

                        // Google AdWords
                        case "gclid":

                        // Common query parameters that now should go into filters
                        case "_":
                        case "UseWorkCopy":
                        case "callback":
                        case "featureClass":
                        case "style":
                        case null:

Thank you. Yeah, that code is what I was referring to as “blacklisted query parameters” in the original question. That code is what we don’t want to keep adding to. :slight_smile:

image

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.