November Happy Hour will be moved to Thursday December 5th.

CustomizedSearchBlock not considering current culture

Vote:
 

Hi,

We are using CustomizedSearchBlock for populating some dynamic results from EPiServer.Find, observing that, its resulting non current culture/language pages, eventhrough the resulted pages are configured with fallback language.

Example:

 A page named (about us), created in en-us and configured fallback with en->en-us

With above

If I visit https://www.mysite.com/en-us/about-us/ or https://www.mysite.com/en/about-us/  both are working.

When I'm using CustomizedSearchBlock to result out the "en" page, its always giving the "en-us" not the "en".

CustomizedSearchBlock Controller code:

public override ActionResult Index(CustomSearchBlock currentBlock)
        {
            IEnumerable<Category> selectedcategoriesLst = null;
            var selectedcategories = ((EPiServer.Core.ICategorizable)currentBlock).Category;
            if (selectedcategories != null && selectedcategories.Any())
            {
                selectedcategoriesLst = selectedcategories.Select(x => _categoryRepository.Service.Get(x));
            }
            int definedHits = currentBlock.CustomizedSearchSettings.NumberOfHits;

            CustomizedSearchSettings settings = GetSettings(currentBlock, defaultHits);
            CustomizedSearchBlock customizedSearchBlock = GetCustomSearchBlock(currentBlock, settings);

            var search = _customizedSearchBlockService.CreateSearchQuery(customizedSearchBlock);

            var contentTypeCategories = _categoryRepository.Service.Get(Constants.ContentTypeCategory)?.Categories;

            var results = search.StaticallyCacheFor(TimeSpan.FromMinutes(5)).GetResult(); // cache search results for 5 minutes
      }

But the above same scenarion working fine in the reguler EPiServer Find search,

Find Reguler Search Query:

                

query = SearchClient.Instance.Search<SitePageData>()
                       .StaticallyCacheFor(TimeSpan.FromMinutes(5))
                       .CurrentlyPublished()
                       .ExcludeDeleted()
                       .PublishedInCurrentLanguage()

Did anyone faced similer issue?

#269041
Dec 26, 2021 5:53
Vote:
 

I am not sure if this should be considered a bug but I believe CustomizedSearchBlock use a UnifiedSearch in Episerver.Find.ClientExtensions that would normally not use. This one does _not_ set the language/analyzer according to PreferedCulture but the other in one in Episerver.Find.Cms.ClientExtensions does.

#271417
Feb 09, 2022 20:35
* 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.