cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Solr Autosuggest Products by name

lohith123
Explorer
0 Likes
639

Hi Guys, while searching i am able to see autosuggestion by product name and code, and here i don't want to show the autosuggestions by code while searching. How can i handle this is Front end ? or is there any code changes required to hide Product code while searching ?

Accepted Solutions (0)

Answers (1)

Answers (1)

andyfletcher
Active Contributor
0 Likes

You should be able to just mark the code column as a non autocomplete field

  • In Backoffice navigate to System -> Search and Navigation -> Indexed Types

  • Select your product type

  • Go to the Indexed Properties tab

  • Scroll down to code and press the 3 dots icon and choose Edit Details from the menu

  • Find Use for auto-complete and uncheck it

  • Save

lohith123
Explorer
0 Likes

After doing this change i can see that product code not displaying while search, but my question here is will the autosuggestion results be same even after making code as false ??

andyfletcher
Active Contributor
0 Likes

Well, no. You're not searching in the code field when you do autocomplete searches if you disable using it in autocomplete.

I'm not really clear on what you are asking.

lohith123
Explorer
0 Likes

In the below method, after disabling autocomplete for product code, component.isDisplaySuggestions() method will be still called or will it only get results from component.isDisplayProducts()?

 @ResponseBody
     @RequestMapping(value = "/autocomplete/" + COMPONENT_UID_PATH_VARIABLE_PATTERN, method = RequestMethod.GET)
     public AutocompleteResultData getAutocompleteSuggestions(@PathVariable final String componentUid,
             @RequestParam("term") final String term) throws CMSItemNotFoundException
     {
         final AutocompleteResultData resultData = new AutocompleteResultData();
 
         final SearchBoxComponentModel component = (SearchBoxComponentModel) cmsComponentService.getSimpleCMSComponent(componentUid);
 
         **if (component.isDisplaySuggestions())
         {
             resultData.setSuggestions(subList(productSearchFacade.getAutocompleteSuggestions(term), component.getMaxSuggestions()));
         }**
 
         if (component.isDisplayProducts())
         {
             resultData.setProducts(subList(productSearchFacade.textSearch(term, SearchQueryContext.SUGGESTIONS).getResults(),
                     component.getMaxProducts()));
         }
 
         return resultData;
     }
 
andyfletcher
Active Contributor
0 Likes

Eh? That's completely unrelated. displaySuggestions is a property of the component being displayed. You can change it in cmscockpit/smartedit or backoffice or just via some impex. Changing whether the code attribute is used in autocomplete doesn't affect the display of suggestions (other than there may be no matches if you start typing in a product code)