Confusion with order id, order increment id and I am not getting order id as 20001201
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.
100000104
|| || |
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
.
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:
Mage::getModel('sales/order')->load($orderId);
PS: If you need it, you can easily get the increment ID from a loaded order:
$order->getIncrementId();
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
Mage::getModel("sales/order")->load($enityId);
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
Mage::getModel("sales/order")->loadByIncrementId($incrementId);
And get by
$order->getRealOrderId(); or $order->getIncrementId();