Blog

Shortening Increment ID length for Orders, Invoices, and Shipments

We recently had a client who needed to shorten the default Magento Increment ID length from the default 9 characters (eg 100000000) to 6 characters.  This can be accomplished by modifying the "increment_pad_length" in the "eav_entity_type" for whatever entity you're wanting to modify.  Here is a screenshot of the resulting table:

magento_shorten_increment_id


If you're wanting to change the number from which Magento starts counting orders/invoices/shipments, or wanting to change the prefix for those entities, check out this great post by Timothy at Elias: http://eliasinteractive.com/blog/magento-ecommerce-how-to-reset-all-test...

Posted on October 3, 2009

Posted by Erik Hansen

Comments

Djay's picture

Is better if you can avoid to

Is better if you can avoid to use an SQL request in an installer :)

$entityType = Mage::getModel('eav/entity_type')->loadByCode('order');
$entityType->setIncrementPadLength(7)->save();

steve's picture

Should have said we are on

Should have said we are on 1.4.1.1

steve's picture

This worked for me: UPDATE

This worked for me:

UPDATE `eav_entity_type` SET `increment_pad_length`=4 WHERE entity_type_code = 'order';
UPDATE `eav_entity_type` SET `increment_pad_length`=4 WHERE entity_type_code = 'creditmemo';
UPDATE `eav_entity_type` SET `increment_pad_length`=4 WHERE entity_type_code = 'invoice';
UPDATE `eav_entity_type` SET `increment_pad_length`=4 WHERE entity_type_code = 'shipment';

nikl's picture

Use this, manually editIng

Use this, manually editIng won't work:

update `eav_entity_type` set `increment_pad_length`=6 where `entity_type_code`='order';

Nellie's picture

Hmm. You know, this didn't

Hmm. You know, this didn't work for us. Do we need to truncate the test orders table first and work with a clean slate? Or do I need to update the last number with the proper length as well for it to work?

ehansen's picture

You should take a look in

You should take a look in your sales_order_entity and look for rows with their entity_type_id equalling 16. If the increment_id field is 7 characters, then the directions worked.

Krystal's picture

Hi, I posted this on the

Hi,
I posted this on the Magento forum just now as well. I followed the directions here to change the default 8 characters for invoice to 7, and I don’t think it worked for me. My credit card extension only allows 7 characters in the invoice field. So I changed invoice, invoice_item, and invoice_comment under the entity_type_code in my database to 7. I’m still getting an error when I try to post an order that says: “Declined: Field Format Error.” Any suggestions on this?

Add comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.