sales_order_item
Table
The sales_order_item
table (sales_flat_order_item
on M1) contains records of all products that were purchased in an order. Each row represents a unique sku
included in an order. The quantity of units that were purchased for a specific sku
is most often represented by the qty_ordered
field.
Product Types
The sales_order_item
captures details on all product types that were purchased. A common practice in Adobe Commerce is to offer configurable products, or in other words, a product that can be customized according to size, color, and other product attributes. Although a configurable product has its own sku
, it can relate to multiple simple products, where each simple product represents a unique product configuration. Refer to configuring products for more information.
For example, consider a configurable product such as a t-shirt. When a customer checks out, they select options to alter the color and size. If the customer selects a color of blue
, and a size of small
, they end up purchasing a simple product like t-shirt-blue-small
which relates back to the parent product of t-shirt
.
When a configurable product is included in an order, two rows are generated in the sales_order_item
table: one for the simple sku
and one for the configurable parent. These two records in the sales_order_item
table can be related to each other through the following join:
- (simple)
sales_order_item.parent_item_id
=> (configurable)sales_order_item.item_id
Therefore it is possible to report on sales of products either at the simple level or at the configurable level. By default, all standard order-item-level
metrics in Commerce Intelligence are configured to exclude the simple products, and only report on the configurable versions. This is accomplished through the Ordered products we count
filter set, which filters on the condition where parent_item_id
is NULL
.
Common Columns
base_price
created_at
item_id
(PK)name
order_id
Foreign key
associated with the sales_order
table. Join to sales_order.entity_id
to determine order attributes associated with the order item.parent_item_id
Foreign key
that relates a simple product to its parent bundle or configurable product. Join to sales_order_item.item_id
to determine parent product attributes associated with simple product. For parent order items (that is, bundle or configurable product types), the parent_item_id
is NULL
.product_id
Foreign key
associated with the catalog_product_entity
table. Join to catalog_product_entity.entity_id
to determine product attributes associated with the order item.product_type
qty_ordered
sku
store_id
Foreign key
associated with the store
table. Join to store.store_id
to determine which Commerce store view associated with the order item.Common Calculated Columns
Customer's email
sales_order_item.order_id
to sales_order.entity_id
and returning the customer_email
field.Customer's lifetime number of orders
sales_order_item.order_id
to sales_order.entity_id
and returning the Customer's lifetime number of orders
field.Customer's lifetime revenue
sales_order_item.order_id
to sales_order.entity_id
and returning the Customer's lifetime revenue
field.Customer's order number
sales_order_item.order_id
to sales_order.entity_id
and returning the Customer's order number
field.Order item total value (quantity * price)
qty_ordered
by the base_price
.Order's coupon_code
sales_order_item.order_id
to sales_order.entity_id
and returning the coupon_code
field.Order's increment_id
sales_order_item.order_id
to sales_order.entity_id
and returning the increment_id
field.Order's status
sales_order_item.order_id
to sales_order.entity_id
and returning the status
field.Store name
sales_order_item.store_id
to store.store_id
and returning the name
field.Common Metrics
Products ordered
Operation: Sum
Operand: qty_ordered
Timestamp: created_at
Revenue by products ordered
Operation: Sum
Operand: Order item total value (quantity * price)
Timestamp: created_at
Foreign Key
Joining Paths
catalog_product_entity
- Join to
catalog_product_entity
table to create columns that return product attributes associated with the order item.- Path:
sales_order_item.product_id
(many) =>catalog_product_entity.entity_id
(one)
- Path:
sales_order
- Join to
sales_order
table to create new order-level columns associated with the order item.- Path:
sales_order_item.order_id
(many) =>sales_order.entity_id
(one)
- Path:
sales_order_item
- Join to
sales_order_item
to create columns that associate details of the parent configurable or bundle SKU with the simple product. Contact support for assistance in configuring these calculations, if building in the Data Warehouse manager.- Path:
sales_order_item.parent_item_id
(many) =>sales_order_item.item_id
(one)
- Path:
store
- Join to
store
table to create columns that return details related to the Commerce store associated with the order item.- Path:
sales_order_item.store_id
(many) =>store.store_id
(one)
- Path: