Magento 2 – Are entity_id and order_id the Same?

databasemagento2

I am creating a module that is going to save orders to a .csv file. The problem now is that I need both the name of the product and the name of the customer. As far as I know these are not stored in the same mysql table. I can get the customer name form the "sales_order" table and the product name form the "sales_order_item". "sales_order" has an id called "entity_id" and "sales_order_item" has an id called "order_id". Are these ids the same?

Or is there a better way of doing this?

Best Answer

Yes they both are same. Magento saves order in sales_order table and products of order are stored in sales_order_item and order_id in sales_order_item table connects that product to its order from sales_order table having entity_id same as order_id .

Related Topic