I am bit confused with order id and order increment id, So can any one help me to understand the difference between these two?

I have an observer for sales_order_place_after where I store sales details in a custom table.

But with

$orderId = $observer->getEvent()->getOrder()->getId();

I get the order ids as normal ids like 112 or 113 or 110 etc not like 20001201

So which is the real order id, 20001201 or 112?

I need to further process order data based on this order id, I use 112, 113 etc. and it works, but I need to clarify this.

4 Answers 4


The difference is:

  • order_id is the internal Magento order ID
  • order increment ID is the ID which you communicate to your customer

You can easily load an order using the internal order_id:


PS: If you need it, you can easily get the increment ID from a loaded order:

  • 1
    You mean Developer use internal Id and clients and other use Increment_id?
    – Charlie
    Commented Jul 8, 2014 at 6:13
  • Charlie, Marius' post below differentiates between the two, and mpaepper's response actually shows the method that is called on an order to return the Increment ID (which is effectively the 'Order ID' in the admin view and in to the customer). Commented Mar 26, 2015 at 23:01

id = the sales_flat_order table primary key value. This is autoincremented for each order you get in your shop. It usually starts from 1 and goes up.

increment id = a "user friendly" number generated prior to placing the order. It must be unique and it is used by online payment methods as reference (but not only).
The increment id by default looks like this.

                  ||   || |
 store view id ---||   || |
                     |   |----- an increment number kept in the table eav_entity_store
    a lot of zeros --|

The number of zeros is variable. It is added using str_pad so that the length of the increment id without the store id is 8.

  • Mind my newbish question, but isn't the 1st byte a prefix value from the EAV table and not store_view_id ? Commented Jul 30, 2014 at 6:40
  • 4
    @someGuyOnTheWeb. Well...yes an no. Technically the prefix (not just first byte...I've worked on projects that had 2 digit prefix) comes from the table eav_entity_store. But for the first order there is no record in that table. So one is created. When it is created the store id is stored as increment_prefix. See how it works in the method Mage_Eav_Model_Entity_Type::fetchNewIncrementId. Starting with line: if (!$entityStoreConfig->getId()) {.
    – Marius
    Commented Jul 30, 2014 at 6:47

A sales order holds two values , entity_id (Order Id) and increment_id (Order Increment Id). The entity_id is the primary key on the orders table. This means that you use this to load the actual order entity. See below


And get by

$order->getId(); or $order->getEntityId();

The increment_id is normally a more friendly number that is often website/store specific i.e 20001201 the 2 in front will often mean that it's an order from your second store/website(cant remember which). This is often refered to as the real order id. You can load an order entity using this increment_id


And get by

$order->getRealOrderId(); or $order->getIncrementId();

The order_id, which I believe is the same as entity_id, is the primary key in the sales_order table used to join all the eav tables together. It is used internally in magento.

order_increment_id is used for displaying to the customer

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.