I have been looking at how to set the timeouts on affiliates to 30-days instead of a lifetime, in our industry the lifetime setting is not beneficial, so instead a quick attempt has been made by following the steps below, feedback would be good.
Set the scheduled task to delete guests to 86400 seconds or 1-day
Edit the DeleteGuestTask class in NopServices -> Customers and adding the following code.
public async System.Threading.Tasks.Task ExecuteAsync()
{
var olderThanMinutes = _customerSettings.DeleteGuestTaskOlderThanMinutes;
// Default value in case 0 is returned. 0 would effectively disable this service and harm performance.
olderThanMinutes = olderThanMinutes == 0 ? 1440 : olderThanMinutes;
await _customerService.DeleteGuestCustomersAsync(null, DateTime.UtcNow.AddMinutes(-olderThanMinutes), true);
// remove affiliates older then 30-days
System.Collections.Generic.IList<Customer> customers = await _customerService.GetAllCustomersAsync();
var affiliates = customers.Where(x => (x.AffiliateId != 0)).Where(x => x.CreatedOnUtc < DateTime.Now.AddDays(-30));
foreach (var affiliate in affiliates)
{
affiliate.AffiliateId = 0;
await _customerService.UpdateCustomerAsync(affiliate);
}
}
If anyone experienced with NOP has feedback, please feel free to respond.