Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento API order id vs. increment id

Tags:

php

magento

I've found that there are two different properties of the order in Magento API available.

order_id and order_increment_id. For sample order they can be something like order_increment_id=100000080 and order_id=81.

The Question Is: What is the difference between them? How they are considered to be used? In the web store UI I see that my order has "Order #" = 100000080. What is order_id property for?

like image 563
Vladimir Avatar asked Jul 12 '10 15:07

Vladimir


People also ask

How to get order id using increment id Magento 2?

It can be done using Magento\Sales\Api\OrderRepositoryInterface interface, all you need to do is use getList() function to fetch order data by order increment id. That's it. You received the Order object for the var_dump in the above output.

How can I get last order ID in Magento 2?

You can fetch Last order id of order by Magento\Checkout\Model\Session Object. Call method to get last order id using below way, $orderId = $this->checkoutSession->getData('last_order_id'); $orderId is your recent order id for a store.

What is Entity ID in Magento?

Entity Id (entity_id column name in table) is the primary key which is used for the table to keep unique id per row and its auto-increment so when a new row is generated/inserted automatically generate latest id.


3 Answers

I've been working with magento API for almost a year now and can assure you that the only ID you need to use is the order_increment_id. It is used as the main ID in the order.info call. The same is true for the invoice and shipment APIs - they also use the appropriate increment id as the main one.

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, but working with the API you needn't worry about it.

like image 70
silvo Avatar answered Nov 15 '22 16:11

silvo


I guess order_increment_id is used for displaying to the customer, and the order_id is for internal use. People find low order ids strange, they are used to seeing 10 digits or so when looking at order ids.

like image 33
greg0ire Avatar answered Nov 15 '22 17:11

greg0ire


What silvo has said is true and thats why there is method called getLastRealOrderId();

like image 30
Kapil Avatar answered Nov 15 '22 16:11

Kapil