cancel
Showing results for 
Search instead for 
Did you mean: 

How to retrieve categories list using fulltext search instead of category code?

jpetvaldsky
Discoverer
0 Kudos

I am not able to retrieve categories list for a full text search (for ex: search text "Kitchen" should display all categories with Kitchen word in the category name) I am able to retrieve categories using category code but not with text search.

Accepted Solutions (0)

Answers (1)

Answers (1)

saood
Participant
0 Kudos
 final CategorySearchEvaluator categorySearch = new CategorySearchEvaluator(categoryCode, searchQuery, page, showMode,
             sortCode, categoryPage);

     ProductCategorySearchPageData<SearchStateData, ProductData, CategoryData> searchPageData = null;
     try
     {
         categorySearch.doSearch();
         searchPageData = categorySearch.getSearchPageData();
     }
     catch (final ConversionException e) // NOSONAR
     {
         searchPageData = createEmptySearchResult(categoryCode);
     }
     searchPageData.getSubCategories();

Defaultly its subCategories, You can define your own attribute allCategories and add the populator as follow.

public class MyProductCategorySearchPagePopulator implements Populator, ProductCategorySearchPageData> {

 /*
  * (non-Javadoc)
  *
  * @see de.hybris.platform.converters.Populator#populate(ProductCategorySearchPageData<QUERY, RESULT, SCAT,
  * ProductCategorySearchPageData<STATE, ITEM, CATEGORY>)
  */
 @Override
 public void populate(final ProductCategorySearchPageData<QUERY, RESULT, SCAT> source,
         final ProductCategorySearchPageData<STATE, ITEM, CATEGORY> target) throws ConversionException
 {
     if (source.getAllCategories() != null)
     {
         target.setAllCategories(source.getAllCategories());
     }


 }

}