I've been using Alphanumeric order increment id's since ~CE 1.1 - they're all set up using an alpha character in the prefix field of core_entity_store.

At the time there was no real documentation surrounding setup and multi-store setup, so we adopted the practice that all order id's were prefixed with an Alpha that represented the store. Order numbers typically looked like M000000003, PA000000004, etc.

Fast-forward 5 years to EE 1.11 and since approximately PE/EE 1.10 we have noticed that orders periodically return a SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'PA00505156' for key 'UNQ_SALES_FLAT_ORDER_INCREMENT_ID' error or something similar. It's infrequent - but my research leads me to the fact that a race-condition while reserving the order ID might be due to the prefix being alpha and not numeric.

I know that Ashley Schroder was working on this a while back, with a Pro edition of a module he developed - http://www.aschroder.com/2010/07/easily-set-a-custom-order-number-in-magento-with-my-free-setstartordernumber-extension/ - But it doesn't look like there has been much movement there, as the pro version isn't on Magento Connect.

Is anyone else using alpha prefixes? How has it performed for you so far? Do you see the same errors?


Yes, we had this issue too.

Quick fix is the following: go to in app\code\core\Mage\Sales\Model\Resource\Quote.php, in the function isOrderIncrementIdUsed replace the row

$bind      = array(':increment_id' => (int)$orderIncrementId); 


$bind      = array(':increment_id' => $orderIncrementId);

Everything should work now.

It's a core file fix, but it's possible to override this functionality with extension (unfortunately till now we have not had time for this)..


| improve this answer | |
  • Thanks for the update. I am anxious to see if this is the solution. I will let you know ASAP. – philwinkle Apr 7 '13 at 21:08
  • My final solution was to replace with a plugin, which works quite well. Coupled with a custom exponential backoff strategy for deadlocks we have eliminated most of the order increment issues. Thanks!! – philwinkle Apr 29 '13 at 3:14

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.