I'm subclassing Nop.Web.Factories.CustomerModelFactory so that i can put some additional items on the customer navigation (my account). My class simply overrides one method however the class is never resolved by autofac.
Class definition is something like this...
public partial class MyCustomerModelFactory : CustomerModelFactory
{
// removed the ctor to keep this short
public override CustomerNavigationModel PrepareCustomerNavigationModel(int selectedTabId = 0)
{
var model = base.PrepareCustomerNavigationModel(selectedTabId);
model.CustomerNavigationItems.Add(new CustomerNavigationItemModel()
{
RouteName = "MyAccountItem",
Title = "My Account Item",
Tab = CustomerNavigationEnum.Info,
ItemClass = "customer-info"
});
return model;
}
}
Registration (in my plugin) is something like this...
builder.RegisterType<MyCustomerModelFactory>()
.As<ICustomerModelFactory>()
.PreserveExistingDefaults()
.InstancePerLifetimeScope();
Pretty much as you'd expect.
I've tried this several ways.
Plan A: In my plugin
Plan B: In a separate class file in nop.web
I've tried changing the registration order. No joy.
Using .PreserveExistingDefaults() made no difference.
The only way i got my class to resolve was to comment out the registration for CustomerModelFactory but I'd rather not do that.
Ideas?