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

How to setup EPiFind Personalization in .NET 6

Vote:
 

I'm trying to setup Personalized Search & Navigation (formerly Personalized Find) following this guide in the link, https://docs.developers.optimizely.com/digital-experience-platform/v1.1.0-search-and-navigation/docs/personalized-search-navigation

What I've done so far are;

- Installed the Integration packages
- Configure the attributes in appsettings.json 
- Retrieve attributes using [EPiServer.Find.Personalization.RefreshPreferences]
- execute the personalized search queries using UsingPersonalization()

Upon starting the site I encountered this error below.


Is there anything else to setup?

Versions used:
- .NET 6
- EPiServer.CMS.AspNetCore 12.12.1
- EPiServer.Personalization.Commerce 4.0.20
- EPiServer.Find.Personalization 15.0.0


#308183
Edited, Sep 08, 2023 2:10
Vote:
 

You are initializing correctly, Check if find settings exist in your appSettings.*.json

#308189
Sep 08, 2023 8:45
Dan Paloma - Sep 08, 2023 9:43
Thanks for your reply. I does exist, the issue we have in Find is with UsingPersonalization() only.
Vote:
 

Can you post the full stacktrace?

#308190
Sep 08, 2023 9:16
Dan Paloma - Sep 08, 2023 9:29
Thanks for your reply. Please see below.

at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at EPiServer.Find.Personalization.RefreshPreferencesAttribute..ctor()
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Boolean inherit)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.<>c.
Vote:
 

By the way this was our error before we encounter the error mentioned in this topic.

The error below shows with these steps;
- Installed the Integration packages 
  > EPiServer.Personalization.Commerce 4.0.20
  > EPiServer.Find.Personalization 15.0.0
- execute the personalized search queries using UsingPersonalization()


[ERR] [EPiServer.Find.Personalization.Api.RefreshPreferenceCommand] Could not execute the refresh command. Personalization unreliable. Error: Object reference not set to an instance of an object.

#308194
Edited, Sep 08, 2023 9:46
Vote:
 

If seems you have a problem with circular reference. Your startup tries to add Commerce, which adds Cms, which adds CmsHost, which initializes your site, and try to initialize some attributes, which tries to get an instance of IClient, which will not be registered until you call AddFind().

I think that you can try to add this before AddCommerce or even AddCms

services.AddSingleton<IClient, Client>();

untested of course, but you can try 

#308196
Sep 08, 2023 11:14
* 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.