magentomagento-1.9magento-rest-api

Magento REST API: in api/rest/orders item_id in order_items is not product_id


I am using Magento REST API with JSON output. A strange thing that I see is the response in api/rest/orders. In the node "order_items", I have a list of the items of the order. The attribute item_id does not match the product_id registered. Here is a example:

"order_items": [
      {
        "item_id": "30",
        "parent_item_id": null,
        "sku": "1043",
        "name": "Product name",
        "qty_canceled": "0.0000",
        "qty_invoiced": "1.0000",
        "qty_ordered": "1.0000",
        "qty_refunded": "0.0000",
        "qty_shipped": "1.0000",
        "price": "19.9000",
        "base_price": "19.9000",
        "original_price": "19.9000",
        "base_original_price": "19.9000",
        "tax_percent": "0.0000",
        "tax_amount": "0.0000",
        "base_tax_amount": "0.0000",
        "discount_amount": "0.0000",
        "base_discount_amount": "0.0000",
        "row_total": "19.9000",
        "base_row_total": "19.9000",
        "price_incl_tax": "19.9000",
        "base_price_incl_tax": "19.9000",
        "row_total_incl_tax": "19.9000",
        "base_row_total_incl_tax": "19.9000"
      }
]

There is no product with id "30" registered.

Where does item_id number come from?


Solution

  • item_id is the ID of that order item. Items are not products. They capture some of the product information at the time of the order, but an order item is its own entity. Take a look at the sales_flat_order_item table if you want to see how they are stored.

    Use the sku to find the product associated with that order item.