We have inherited a site where the original developer hasn't deleted their test data from what seems to be testing a bulk import of customers. There are 500 pages of nonsense [email protected] customers which while not doing any harm is making creating marketing email lists more difficult than they should be.
Does anyone know how to bulk delete customer data (and any related purchase info) and the associated members from Merchello.
Going to answer my own question in case anyone comes along in the future and wonders.
What I did was perform a search on the merchCustomer table to find the test customers (as all had the same email domain a simple like was all that was required).
I then created a CSV with the GUID pk and loginName of the customer and wrote a little script (shown below) to delete both the Umbraco member and the customer.
It worked well though took around 3 hours to delete all 5000 test customers.
IMemberService serv = ApplicationContext.Current.Services.MemberService;
ICustomerService custServ = MerchelloContext.Current.Services.CustomerService;
int count = 0;
string[] lines = System.IO.File.ReadAllLines(@"C:\test_cust.csv");
foreach (string line in lines)
{
string[] memberData = line.Split(',');
if (memberData.Length == 2)
{
try
{
var member = serv.GetByEmail(memberData[1]);
serv.Delete(member);
Guid id = new Guid(memberData[0]);
var customer = custServ.GetByKey(id);
if (customer != null)
{
custServ.Delete(customer);
}
else
{
<p>Could not find customer @memberData[0]</p>
}
count++;
}
catch (Exception ex)
{
<p>Could not delete @line</p>
}
}
}
<p>@count Deleted</p>
Bulk deleting customer data (old test customers)
We have inherited a site where the original developer hasn't deleted their test data from what seems to be testing a bulk import of customers. There are 500 pages of nonsense [email protected] customers which while not doing any harm is making creating marketing email lists more difficult than they should be.
Does anyone know how to bulk delete customer data (and any related purchase info) and the associated members from Merchello.
Going to answer my own question in case anyone comes along in the future and wonders.
What I did was perform a search on the merchCustomer table to find the test customers (as all had the same email domain a simple like was all that was required).
I then created a CSV with the GUID pk and loginName of the customer and wrote a little script (shown below) to delete both the Umbraco member and the customer.
It worked well though took around 3 hours to delete all 5000 test customers.
is working on a reply...