Plugin using GetAllCustomers()

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 years ago
Trying to return list of registered customers:

IPagedList<Customer> customers = _customerService.GetAllCustomers(customerRoleIds: new int[] {3});

getting: NullReferenceException

trying:

            foreach (var cust in customers)
            {
                if (cust.isRegistered())

returns same error...

What am I doing wrong?!
8 years ago
Explained:

     var RegisteredRoleId = new[] { customerService.GetCustomerRoleBySystemName(SystemCustomerRoleNames.Registered).Id };
     IPagedList<Customer> customers = _customerService.GetAllCustomers(customerRoleIds: RegisteredRoleId);

Returns all registered customers as advertised.  The reason GetAllCustomers() appeared to work is that I was processing only the first 500 and the error was coming into play with:

var whatstate = _stateProvinceService.GetStateProvinceById(cust.GetAttribute<int>(SystemCustomerAttributeNames.StateProvinceId));

and use of whatstate.Name

apparently some bogus StateProvinceId data...
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.