Search results order


https://forum.kartris.com/Topic1148.aspx
Print Topic | Close Window

By saturation - Thu 28 Jul 2011
I'm looking to order my search results by product name (descending).   Is there a way to add this to the code?  v.1.3.
By Mohammad - Thu 28 Jul 2011
1. If you want to control the whole results order (so to ignore the best matches), then you can do that from the search stored procedure, which could be either "spKartrisDB_Search" (default) or "spKartrisDB_SearchFTS" (if you enabled Full Text Search in your database).

Go to the 4th or 5th line from the bottom of the stored procedure (Line 240 +/- from the top):

Replace
ORDER BY TotalScore DESC

By
ORDER BY P_Name DESC

OR

2. If you want to keep the best matches at the top pages, but order the results per page, you need to do that from the code behind.

Go to "UserControls\Templates\ProductTemplateSearchResult.ascx.vb" find LoadSearchResult Sub:

Replace:
rptSearchResult.DataSource = ptblResult
rptSearchResult.DataBind()

By:
Dim dvResults as DataView = ptblResult.DefaultView
dvResults.Sort = "P_Name DESC"
rptSearchResult.DataSource = dvResults
rptSearchResult.DataBind()