Reused the wasted CustomerIds

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Hi,

The nop designed how to filter the search engine by judge the useragent, but this can't not filter all crawlers 100 percent, so nop generate thousands of guest customers and those custmors deleted by Delete guests task. This is wasted a lot of CustomerIds in result. So I want to design a function to reused the wasted CustomerIds which the delete guest task deleted.

First, now that Detete guests task can know which customers to deleted, so we can known which CustomerIds can be resused. Because I just need the customerid field in customer table, so I let task delete the guest customer in customer table, then I store the customerid into a my new table DeletedGuestCustomer which just have one field named Id as premary key and IsUsed as bool to judge this customerid can be used or not.

Second, when a new customer registered, I will get the min customerid from DeletedGuestCustomer and judge whether this customerid is in Customer Table or not, if not, it means that I can use this customerId as a new customer's id, if yes, delete this customerid in DeletedGuestCustomer table and get next one.

Now my problem is how to used repository's insert function to insert a new customer with a customerid, as the Customer table's Id field is auto-increment and the identity seed is bigger than this customerid now.

Anyone can help, thank you.

Alex
7 years ago
For what it's worth, if I were to do this, I would ...

Update this method
\Libraries\Nop.Services\Customers\CustomerService.cs
         public virtual Customer InsertGuestCustomer()

To do some type of SELECT TOP 1 ... WHERE Deleted AND Is Guest

Because, who really cares which deleted record you use?  I.e.  why bother with the overhead of dealing with "... when a new customer registered, I will get the min customerid from DeletedGuestCustomer"
6 years ago
I have thought about this way, but when we reused the deleted guest customer, we can't not use the customers that have any shoppingcart item and need to clear this customer all account information like blog comments. so I decide to delete guest customer and reuse it's id.
6 years ago
If the customer had been deleted by the task, then it would not have had shopping cart items.
6 years ago
Give guest accounts their own temp table until converted to a registered account. Then they can use as many id's as they want without affecting the actual customers table.

Regards
6 years ago
usauto wrote:
Give guest accounts their own temp table until converted to a registered account. Then they can use as many id's as they want without affecting the actual customers table.

Regards

That would be a major code change.  All the relations (and thus SQL JOINs) are to/from the Customer table.
6 years ago
New York wrote:
Give guest accounts their own temp table until converted to a registered account. Then they can use as many id's as they want without affecting the actual customers table.

Regards
That would be a major code change.  All the relations (and thus SQL JOINs) are to/from the Customer table.


I never said it would be easy, lol. nopC has had its share of "major" code changes in the past.

Regards
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.