3

Is there a way to change the customer ID to start with 00001. Now it's just 1. I need this for importing into a different system.

So each customer number starting with 00001, 00002 and so on...

3 Answers 3

6

I would strongly advise against altering core tables or their auto increment. Instead translate it when retrieved for export/import using str_pad or sprintf i.e.:

$id = 1; $exportId = str_pad($id, 5, '0', STR_PAD_LEFT); -> 3v4l example

OR

$id = 1; $exportId = sprintf('%05d',$id); -> 3v4l example

4

To use increment ids for customers (the same way as for orders), you have to enable them first, via configuration:

Customer Configuration > Create New Account Options > Generate Human-Friendly Customer ID

Afterwards you can change padding size in the eav_entity_store (there is no admin interface for it, you have to do it directly in the database. The entity_type_id for customers is 1.

(Note that this is not related to the MySQL auto increment id and you are not altering core tables)

5
  • My latest customer ID at the moment is 10. I want my next customer to have the ID '45630'. and the for every customer it should increment this id. I've set this in eav_entity_store for last_increment_id but no luck. Commented Oct 31, 2016 at 6:02
  • Still I am not getting the use of Generate Human-Friendly Customer ID . Could you please elaborate? @Fabian
    – Keyur Shah
    Commented Nov 14, 2017 at 14:10
  • @KeyurShah if you enable this, the increment_id column is used for customer numbers, instead of the entity_id column. If not, increment_id is not populated. Commented Nov 14, 2017 at 16:37
  • Thanks for answer, I enabled it still I can not see any effect on new customer created Id. am I missing something ? @FabianSchmengler
    – Keyur Shah
    Commented Nov 14, 2017 at 18:55
  • Where do you look for an effect? Commented Nov 14, 2017 at 18:57
-2

Order, credit, invoice and shipping ID:

In your store database go to eav_entity_store and change the values of increment_last_id, you can change all the number types (order,credit,invoice,shipping).

This is a great source for more in-depth information about this: Link

Customer ID:

The customer ID increment can be altered from the customer_entity table. Or by this SQL command:

ALTER TABLE customer_entity AUTO_INCREMENT = 00001;
6
  • but I want to achieve for every customer ID starting with 00001, 00002, 00003. eav_entity_store and increment_last_id looks like order ID not customer ID.
    – Webjuice
    Commented Jan 28, 2015 at 11:00
  • Sorry for the wrong answer, I just updated the post. Hope it helps. Commented Jan 29, 2015 at 14:15
  • so when i run this query it will change all customers id to 00001, 00002 and so on ?
    – Webjuice
    Commented Jan 29, 2015 at 14:31
  • Getting error: ALTER TABLE customer_entity AUTO_INCREMENT =0001 MySQL said: Documentation #1146 - Table 'electroweld.customer_entity' doesn't exist
    – Webjuice
    Commented Feb 4, 2015 at 10:36
  • This is a terrible idea. Modify the data outside of Magento's DB or build a separate table to do the translation. Messing with the EAV system is going to land you in a world of hurt; especially if you don't document the fact that you have to run manual SQL queries to get a fresh install to this state. If you're simply doing this for an import into another system then build it out in your import/export process. Commented Jun 5, 2015 at 22:18

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.