I'm redoing an existing shop in Magento, the client is requesting that when customers register, their customer number gets set to their mobile number (which is required, and asked for at registration). Now I personally don't think this is good practice, but it's something they're set on having. I'm looking into a proper way to do this. I am not quite sure what to override or where to start, as I've never altered registration before.

Is this possible? And if so, could you help point me in the right direction on how to accomplish this.

  • What customer number are you talking about? The customer_id from the database? Commented Sep 9, 2014 at 16:21
  • The "id" visible in the customer overview. I think it's called "entity_id" in the database, but i'm not 100% sure.
    – DrunkWolf
    Commented Sep 9, 2014 at 17:30
  • Yes i'm aware that it's not good practice, and i would never do it for my own store. But since they only sell in 1 country, telephone numbers should be a unique number. I figured if i put the auto-increment number high (11 digits) or low (since they dont have that many customers that the number will reach 10 digits) I shouldn't have any conflict in overwriting it with the telephone number? But then i'm still not sure how to actually do this automatically upon registration.
    – DrunkWolf
    Commented Sep 9, 2014 at 17:45
  • So each time a customer changes their phone number you will want to change the entity id of the customer? Why not just make a new field and use that? Commented Sep 9, 2014 at 17:59

2 Answers 2


It looks like you mean the entity_id with "customer number", if so: No, this isn't possible in a reasonable way. However, there is the field increment_id which is meant to be used for customer numbers and can contain custom logic.

By default, it is not used at all, but you can activate it in System > Configuration > Customer Configuration > Create New Account Options > Generate Human-Friendly Customer ID

Then it uses an increment model, similar to order numbers. You can define your own increment models as described here but in your case you will need to set the value directly in an observer and not activate the abovementioned setting, because the value depends on other attributes and not on the previous number.

So, write an observer vor customer_save_before like this

public function setCustomerNumber(Varien_Event_Observer $observer)

I would highly advise against editing the entity_id in MySQL.

You should create a new attribute that is unique for the customer phone number. You can then add this number to the admin grid so your client can see it.

This is the scenario that can happen:

A customer is given the ID of a phone - That id is also the database key Two years pass by and the customer has since left their company and their phone number is old and is re-issued.

A new customer signs up with the same phone number and they can't because the number already exists.

  • I could do that, but the problem is that they use accounting software that uses an expensive, non customizable importing program that won't import the new field. Since this accounting software is what they mostly look at, using the mobile number as customer number allows them to call the client without having to look up the number in Magento. I agree though that it's far from ideal to use the mobile number. A way around the issue you present is padding it with 2 extra numbers, but I agree with you that it's not good practice.
    – DrunkWolf
    Commented Sep 9, 2014 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.