I am using Sitecore 9.0.1 with SXA 1.7 .I have overriden the ContentPredicate() method for chinese language search box drawback from Sitecore.XA.Foundation.Search.Services.SearchService and i want to apply a patch for it so i have created config file under App_Config/Include folder but this patch is not working.
If i directly edit the Sitecore.XA.Foundation.Search the overriden method is getting called and its working but when i try to apply a patch it is not.
Sitecore.XA.Foundation.Search file:
<register serviceType="Sitecore.XA.Foundation.Search.Services.ISearchService, Sitecore.XA.Foundation.Search" implementationType="Sitecore.XA.Foundation.Search.Services.SearchService, Sitecore.XA.Foundation.Search" lifetime="Singleton"/>
<!-- <register serviceType="Sitecore.XA.Foundation.Search.Services.ISearchService, Sitecore.XA.Foundation.Search" implementationType="SearchFeatureCustomization.CustomSearchService, SearchFeatureCustomization" lifetime="Singleton"/>-->
Here is my overriden code:
namespace SearchFeatureCustomization
{
public class CustomSearchService : Sitecore.XA.Foundation.Search.Services.SearchService
{
protected override Expression<Func<ContentPage, bool>> ContentPredicate(string content)
{
Expression<Func<ContentPage, bool>> expression = PredicateBuilder.True<ContentPage>();
if (string.IsNullOrWhiteSpace(content))
{
return expression;
}
foreach (string item in content.Split().TrimAndRemoveEmpty())
{
string t = item;
expression = expression.And((ContentPage i) => i.AggregatedContent.Contains(t) || i.AggregatedContent.Equals(t, StringComparison.InvariantCultureIgnoreCase));
}
return expression;
}
}
}
This is my patch file:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
<sitecore>
<services>
<pipelines>
<initialize>
<register type="SearchFeatureCustomization.CustomSearchService, SearchFeatureCustomization"
patch:before="processor[@type='Sitecore.XA.Foundation.Search.Services.ISearchService, Sitecore.XA.Foundation.Search']" lifetime="Singleton" resolve="true"/>
</initialize>
</pipelines>
</services>
</sitecore>
</configuration>
can anyone please help where i am going wrong.
Thanks