Try our conversational search powered by Generative AI!

Find Unified Search and Commerce Catalog Content: No URL on searchHit's returned

Vote:
 

Hello,

I have been having an issue with Unified Search results for Commerce product variations that get returned. I have tried several ways to project the url to the results with little success. The only time I did get it to work was using the depricated UnifiedSearchRegistry.CustomizeProjection. That broke when I upgraded to the latest version of Find. Seems weird to me that Commerce content is not fully supported by default in the latest version of Find. Perhaps I am missing something? To even get the indexed variants to show in Unified Search results, I have to manually add them to the UnifiedSearchRegistry via an InitializableModule. 

Here is how I am trying to project the URL in my InitializableModule:

var registry = SearchClient.Instance.Conventions.UnifiedSearchRegistry;

registry.Add()
            .ProjectUrlFrom(product => product.ContentLink.GetUrl());

The GetUrl() is a custom extension method. Here is how I am looping through the results and assigning the URL:

foreach (var item in results)
{
      var test = item.GetOriginalType().Name;               
      searchItems.Add(new SearchHit()
      {
             Name = HttpUtility.HtmlDecode(item.Title),
             Url = item.Url,
             Teaser = HttpUtility.HtmlDecode(item.Excerpt)
      });                
 }

The url on the variantion results is always empty. Any help on with this would be grately appreciated. Here are the versions I am using with everything:


  
  
  
  
  
  
  
  
  
  
  

Thanks in advance!

#151406
Jul 20, 2016 16:56
Vote:
 

So, I was able to figure this out. I ended up having to reindex all of the content for the variant URL to start getting assigned to the Unified search hit. I did still have to do a little bit of tweaking. In my init module, I still had to add my variants to the Unified search registry like I posted above.

Initially, the URL that was getting set for each was throwing a 404. For some reason, Find was appending /en at the beginning. Since I had 'en' set as the default culture of the website in the cms admin, I am not sure why Commerce wasn't picking it up. So, what I ended up doing for a solution to this was implementing SearchHitUrl, which is part of ISearchContent, on my product variation classes.

 public virtual string SearchHitUrl { get { return SeoUri; } }

Everything is now working as expected.

#151472
Edited, Jul 22, 2016 23:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.