Magento API order id vs. increment id

2020-08-13 07:44发布

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?

标签: php magento
5条回答
Lonely孤独者°
2楼-- · 2020-08-13 08:07

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

查看更多
Animai°情兽
3楼-- · 2020-08-13 08:10

What Silvo says is correct however there are some circumstances where the order_id is referenced in the API and is the only reference you have to get back to the order.

For example if you generated a list of SalesOrderInvoices or SalesOrderShipments then the reference back to the order, from the objects in the list, is given as the order_id, not the order_increment_id. Whilst you can get the SalesOrderEntity from the order_increment_id directly through a SalesOrderInfoRequest you will need to search for that order_id by using a SalesOrderListRequest with a filter on "order_id".

查看更多
forever°为你锁心
4楼-- · 2020-08-13 08:17

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.

查看更多
我命由我不由天
5楼-- · 2020-08-13 08:19

For magento 2.1 (pehaps behaviour not the same for other versions ?!) you should use entity_id. I checked it on for SOAP API. Sometimes entityId looks like incrementId and this can lead to missunderstanding.

For example

  • i try to call SalesOrderRepositoryV1GetList with parameter id=275
  • received order has <entityId>275</entityId> <incrementId>000000276</incrementId>
  • i try to call SalesOrderRepositoryV1GetList with parameter id=000000276
  • received order has <entityId>276</entityId> <incrementId>000000277</incrementId>

In UI you will see 000000277 for 275 and 000000276 for 276

查看更多
▲ chillily
6楼-- · 2020-08-13 08:28

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.

查看更多
登录 后发表回答