Here's my DependacyRegistrar code:
namespace Nop.Plugin.Colhouse.Customizations;
public class DependencyRegistrar
{
public static int Order => 0;
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
RegistrationExtensions.RegisterType<CustomerAttributeService>(builder).As<ICustomerAttributeService>().InstancePerLifetimeScope();
RegistrationExtensions.RegisterType<ColhouseCookieAuthenticationService>(builder).As<IAuthenticationService>().InstancePerLifetimeScope();
}
}
And here is my override:
namespace Nop.Plugin.Colhouse.Customizations.Services
{
public class CustomerAttributeService : Nop.Services.Customers.CustomerAttributeService
{
private readonly IRepository<CustomerAttribute> _customerAttributeRepository;
private readonly IWebHelper _webHelper;
private readonly ISettingService _settingService;
private readonly IStoreContext _storeContext;
public CustomerAttributeService(IStaticCacheManager cacheManager,
IRepository<CustomerAttribute> customerAttributeRepository,
IRepository<CustomerAttributeValue> customerAttributeValueRepository,
IWebHelper webHelper,
ISettingService settingService,
IStoreContext storeContext)
: base(customerAttributeRepository, customerAttributeValueRepository, cacheManager)
{
_customerAttributeRepository = customerAttributeRepository;
_webHelper = webHelper;
_settingService = settingService;
_storeContext = storeContext;
}
public override async Task<IList<CustomerAttribute>> GetAllCustomerAttributesAsync()
{
ColHouseDesignsSettings settings = await _settingService.LoadSettingAsync<ColHouseDesignsSettings>(0);
if (settings.Enable)
{
string currentUrl = _webHelper.GetThisPageUrl(false);
if (!currentUrl.ToLowerInvariant().Contains("admin"))
{
Store currentStore = _storeContext.GetCurrentStore();
bool isWholsesale = currentStore.Id == settings.WholesaleStoreId;
bool isRetail = currentStore.Id == settings.RetailStoreId;
if (isWholsesale)
{
if (!string.IsNullOrEmpty(settings.WholesaleCustomerFormFieldIds))
{
List<int> wholesaleCustomerFormFieldIds = settings.WholesaleCustomerFormFieldIds.Split(',').Select(int.Parse).ToList();
IOrderedQueryable<CustomerAttribute> query2 = _customerAttributeRepository.Table.Where((Expression<Func<CustomerAttribute, bool>>)((CustomerAttribute ca) => wholesaleCustomerFormFieldIds.Contains(ca.Id))).OrderBy((Expression<Func<CustomerAttribute, int>>)((CustomerAttribute ca) => ca.DisplayOrder));
return query2.ToList();
}
return new List<CustomerAttribute>();
}
if (isRetail)
{
if (!string.IsNullOrEmpty(settings.RetailCustomerFormFieldIds))
{
List<int> retailCustomerFormFieldIds = settings.RetailCustomerFormFieldIds.Split(',').Select(int.Parse).ToList();
IOrderedQueryable<CustomerAttribute> query = _customerAttributeRepository.Table.Where((Expression<Func<CustomerAttribute, bool>>)((CustomerAttribute ca) => retailCustomerFormFieldIds.Contains(ca.Id))).OrderBy((Expression<Func<CustomerAttribute, int>>)((CustomerAttribute ca) => ca.DisplayOrder));
return query.ToList();
}
return new List<CustomerAttribute>();
}
}
}
return await GetAllCustomerAttributesAsync();
}
}
}
At any rate this is not working and I am not sure why. My only thought is that it is not registered properly.
Thanks!
Rob