I have been overriding the function saveOrderAction in the OnepageController.php (/app/code/core/Mage/Checkout/controllers) with my custom code.

I have implemented the logic for this successfully. I believe at this point at the start of the function as the order hasn't been completed there is no order ID. Instead I have access to the 'quote ID'.

What I need to do now is find out where the Order ID is generated for the order. My first question is which file/function is best to override for when the Order ID is created?

My second question is, is there a way to link the quote ID to the Order ID which is generated?

Essentially my aim is to get the order ID of the currently ordered items so I can do further custom processing.

My observer code is through this path: /local/James/Aftercheckout

config.xml - /local/James/Aftercheckout/etc

Observer.php - /local/James/Aftercheckout/Model

Contents of config.xml:

<?xml version="1.0"?>





Code for Observer.php :

class James_Aftercheckout_Model_Observer

public function test($observer)
    $quote = $observer->getEvent()->getQuote();
    $incrementId = $quote->getReservedOrderId();

    $to = "[email protected]";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message! .".$incrementId;
    $from = "[email protected]";
    $headers = "From:" . $from;
  • You are referring to the physical ID (the table increment id), the one that looks like 4, 17 and so on? or the order increment id, the one that looks like 100000054?
    – Marius
    Jul 3, 2013 at 9:12
  • Hi, I'm looking for the order increment id. Jul 3, 2013 at 9:16

1 Answer 1


The increment id of the order is created when the order is submitted, in this method Mage_Sales_Model_Service_Quote::submitOrder(). The line responsible for the creation is $quote->reserveOrderId();.
If you want to access it you can hook onto the event sales_model_service_quote_submit_before.
You will be able to get the increment id in you observer like this:

public function doSomething($observer){//observer for the event
    $quote = $observer->getEvent()->getQuote();
    $incrementId = $quote->getReservedOrderId();
    //do stuff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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