I'm using the code available here to generate orders programmatically (importing from an older in-house system) and its actually working quite well. I've made some changes to check/create customers as needed, but it makes the orders just fine with one exception. I'd like to set the order number of these imported orders to match the number they had in the old system (a simple 4 to 6 digit number) without affecting magento's normal order numbering (these imported orders will be in a different "store" from new orders anyway).

I've tried a few variations for setting the IncrementID right before saving the order, but nothing seems to stick.

Some of the things I've tried:


  • Magento automatically set an increment id if this one hasn't been defined. See _beforeSave in app/code/core/Mage/Sales/Model/Order.php. Are you sure you setting it properly? Can you paste the code you're executing? May 15, 2015 at 20:53
  • 1
    Are you sure you want to use a custom increment ID? If all you're trying to do is create a reference between the new system and old system, perhaps you might be better off creating a new column to store the old ID, letting Magento generate its own increment IDs. Just trying to approach the problem from a different angle.
    – Agop
    May 15, 2015 at 20:58
  • I have to agree with Agop. I'd recommend maintaining Magento's internal increment and use a custom column to associate IDs between the two datasets. May 16, 2015 at 15:30
  • Problem is, adding a custom field to the order is going to require permanent changes to the DB schema & a module/plugin to display that in the admin, vs a one-time change on import to alter the saved order number. I'm also not looking to change the increment system, I want to keep that as-is for all future orders, I just want to override the IncrementID for these imported orders.
    – Caleb
    May 18, 2015 at 13:36


Your Answer

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

Browse other questions tagged or ask your own question.