Search Products - splitted keywords

2 месяца назад
Hello,
I'm pretty new to NopCommerce Development and probably I miss something obvious.
My requirement is: I need to search my products for different keywords, splitting every term and looking for them separately.
I'm testing everything using Visual Studio with debugger attached to see exactly what's going on behind the curtain.

For example: My product has in its description "red paper disc"; using the standard code, if I search for "red disc" I get no result.
Following the hints from other posts I managed to modify ProductService.cs and have SearchProductsAsync method to execute my search considering "red" and "disc" as separate search terms, and the result of this method is now populated with the correct items.

So I expected to have solved my problem. No way.
I still get "No result found" message on my search page, even if (debugger attached) my model has items in it.

If I look for "red paper disc" the search page gives me the expected results, and the model of the page looks absolutely identical to the one of the previous call that gives me no results.

I really have no clue. Please help.
2 месяца назад
RE: "I still get "No result found" message on my search page, even if (debugger attached) my model has items in it."

I suggest you Insert a breakpoint in the .cshtml page and continue debugging.
2 месяца назад
New York wrote:
RE: "I still get "No result found" message on my search page, even if (debugger attached) my model has items in it."

I suggest you Insert a breakpoint in the .cshtml page and continue debugging.


Unfortunately I could not manage to debug Razor pages.
The weird thing is that I managed to log the activity of my Search page and save the model I pass to the Razor View.
This is what I get:

PAGE WITH RESULTS:
{"q":"red paper disc","cid":0,"isc":false,"mid":0,"vid":0,"sid":false,"advs":false,"asv":false,"CatalogProductsModel":{"UseAjaxLoading":true,"WarningMessage":null,"NoResultMessage":null,... 


PAGE WITH NO RESULTS:
{"q":"searching something impossible to find","cid":0,"isc":false,"mid":0,"vid":0,"sid":false,"advs":false,"asv":false,"CatalogProductsModel":{"UseAjaxLoading":true,"WarningMessage":null,"NoResultMessage":"Nessun prodotto trovato con i criteri di ricerca espressi",


PAGE WITH RESULTS THAT SHOWS NO RESULTS!:
{"q":"red disc","cid":0,"isc":false,"mid":0,"vid":0,"sid":false,"advs":false,"asv":false,"CatalogProductsModel":{"UseAjaxLoading":true,"WarningMessage":null,"NoResultMessage":null,... 


In both #1 and #3 "NoResultMessage" is null, but in case #3, I have the damn message visible even if it is not in the model and I really don't understand why.

2 месяца назад
I managed to debug the whole project with a new database and sample data.
The fact is this:
If I inspect the browser activity I see this:
When I execute a search I have a first call to page:
https://localhost:52859/search?q=pride+prejudice&advs=true&cid=0&isc=true&mid=0&sid=true&advs=false&isc=false&sid=false

The cshtml code correctly has a model with data in it.

Immediately after that I have a second call:
https://localhost:52859/filterSearch?q=pride+prejudice&advs=true&cid=0&isc=true&mid=0&sid=true&advs=false&isc=false&sid=false


This second call doesn't seem to pass through the "SearchProductAsync" in my ProductService, and the model attached to the cshtml has no items in it.

I don't understand what route does this second call is doing and what method in the service it is using.
ANY IDEA?