Kentico 11- 12 upgrade search issues

Targutai Yesugei asked on November 18, 2019 12:47

Hello everyone! I'm stuck with following search problems during upgrade:

Problem A:

I'vegot an aspx search control with such code:

public class SmartSearchContextWrapper : ISmartSearchContextWrapper
    public object GetSearchValue(string id, string columnName)
        //In Kentico 12 id should be SearchResultItem
        return TransformationHelper.HelperObject.GetSearchValue(id, columnName);

    public string GetSearchResultUrl(string id, string type)
        return TransformationHelper.HelperObject.SearchResultUrl(id, type, false) ?? string.Empty;


        protected static string HighlightFoundText(string text)
        //I'm suggested to use SearchResultItem too
        var result = SearchHelper.Highlight(text, "<span style=background-color:yellow>", "</span>") ?? string.Empty;
        return HttpUtility.HtmlDecode(result);

And Kentico 12 upgrade tool says that I have to use some SearchResultItem instead of string (in TransformationHelper.HelperObject.GetSearchValue and SearchHelper.Highlight methods). How can I acquire the object of this type from string? It's constructor says that i need to pass SearchResult to it. Is there any examples?

Problem B: There is a method which counts search results count in my search control:

    protected void SearchResultList_OnOnSearchCompleted(bool visible)
        var numberOfResults = SearchContext.CurrentParameters?.NumberOfResults ?? 0;
        ResultsFound.Text = numberOfResults.ToString();

Upgrade tool says, that I need to use members of corresponding CMS.Search.SearchResult or CMS.Search.SearchResultItem. Again, zero ideas of how to achieve this. I can't understand how can I receive this SearchResultItem object.

Thank you. Any ideas would be appreciated.

   Please, sign in to be able to submit a new answer.