I have a client that requires custom order, invoice and shipment number to be present in emails and while printing them out... The best possible modification would be to change the code that assigns those numbers.

How would I go about changing this so Magento generates these numbers the way i want them to?

Thank you!!!

Edit: I'm sory that I wasn't specific enough first time... i don't need a way to change the order increment or starting number but rather change the whole logic of assigning/generating those numbers.

Eg: I would like to have a order number that would be todays date (220114) with a postfix which would be something like the number of todays order (if its the third order today then that postfix wold be 3), invoice number would have additional postfix that would correspond to payment method used and shippment number would a postifx that would describe the shipping method used.

So what i really need is location of the magento code that is responsible for generating current/default numbers and switch that code with my own as needed.


It is possible to create a completely new EAV increment model. This is where the magic happens when getting the next ids :)

Firstly you can see what the current model is by looking at the table eav_entity_type under the column increment_model. For example to order has the following set.


You can create your new model and set it for orders via an install script.

class My_CustomEav_Model_Entity_Increment_New extends Mage_Eav_Model_Entity_Increment_Abstract
    public function getNextId()
        // Some magic here to get the unique  vaue you want and return it

The table eav_entity_store holds a few more pieces of important information. Here you can store increment_prefix varchar(20) which is the prefix that is normally added to the increment, I think the default it 1, and increment_last_id varchar(50) this stores the last id used for the entity type on a given store, note that without changing the table definition you will be limited to varchar(50), though that should be enough....maybe.

NOTE I have not tested this myself as I have never needed to but it should all work nicely if the ids are unique.

| improve this answer | |
  • Beautiful answer that covers everything i wanted to know and more... THANK YOU! – BegBox Jan 23 '14 at 17:24
  • no problem, I would be really careful when doing this and make sure it is really well tested as I would be worried that the order number would get messed up. – David Manners Jan 23 '14 at 17:25
  • 1
    I have development environment, backups and enough time to test before pushing to public domain..Will post update on how it went – BegBox Jan 23 '14 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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