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

Issue with Using IProfileMigrator in Episerver Commerce when migrating/merging an anonymous Cart to a logged in user cart

Vote:
 

Hello, I am currently having an issue with the IProfileMigrator I have implemented. It seems that no methods get called in this when I am migrating carts. I have implemented the IProfileMigrator because we have some custom logic needed for line items that have custom meta properties. (the default logic collapses them into a single line item when those meta properties are supposed to be unique) It seems that it only calls the base logic from

  <add name="ProfileModule" type="EPiServer.Business.Commerce.HttpModules.ProfileModule, EPiServer.Business.Commerce" />

inside the web config. I have tried removing this from the web config but it still never hits my IProfileMigrator.

The migrator looks like this:

    [ServiceConfiguration(typeof(IProfileMigrator), Lifecycle = ServiceInstanceScope.Hybrid)]
    public class CEProfileMigrator: IProfileMigrator
    {
      //blah blah my 3 methods
    }

The dev I am working with set the lifecycle as such but I am not sure that is correct.

And its even more apparent in the initializable module where we have it added as a singleton.

        public void ConfigureContainer(ServiceConfigurationContext context)
        {
            context.Services.AddSingleton<IProfileMigrator, CEProfileMigrator>();
        }

Any insight as to why my profile migrators logic does not get called when the anonymous user logs in? I am out of ideas as to why its not being intercepted.

#207402
Sep 18, 2019 23:11
Vote:
 

Is there any way to force this to intercept and prevent the default migration from ProfileModule from being run? This issue is intermittent and it is making it incredibly difficult to track down

#207403
Sep 18, 2019 23:18
Vote:
 

What could be the possible reasons for the IProfileMigrator to not be called sometimes?

#207404
Sep 18, 2019 23:31
Vote:
 

I have no idea how the IProfileMigrator works, but if you want to intercept the regular IProfileMigrator then in the documentation to episerver (https://world.episerver.com/documentation/developer-guides/CMS/initialization/dependency-injection/)

then you use something like this

context.Services.Intercept<IProfileMigrator>((locator, defaultProfileMigrator) => new CEProfileMigrator(defaultProfileMigrator));
#207413
Sep 19, 2019 10:30
Vote:
 

You would need this in web.config

  <add name="ProfileModule" type="EPiServer.Business.Commerce.HttpModules.ProfileModule, EPiServer.Business.Commerce" />

As it's the registration of the module, which itself will call to IProfileMigrator.

The lifecycle is a bit complicated in this case (http modules/static), so I will need to check. it might be that we did something wrong ...

#207428
Sep 19, 2019 16:52
Vote:
 

It works well for me. However I'm on 13.7.1 which is much newer than yours ... 

#207430
Sep 19, 2019 17:09
* 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.