Question

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?

Was it helpful?

Solution

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); 

with

$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)..

Regards.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top