Skip to Content

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

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Jun 19, 2019 at 07:26 AM
     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());
         }
    
    
     }
    
    

    }

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.