Magento – Why are both configurables and simples stored in sales_flat_order_item

configurable-productdatabasesales-ordersimple-product

I am working with sales_flat_order_item using direct sql and I can't make sense of why both configurable and simple products are inserted into the sales_flat_order_item table. What is the reason behind this?

It seems like a lot of redundant data to just keep track of whether the product was added via a configurable product page vs a simple product page.

I'm just trying to understand this behaviour in case I'm missing something which could impact the accuracy of my queries.

Best Answer

mageApprentice,Magento used for business logic.It main for variance feature of configurable.Whenever a configurable product cart it save two row one is configurable product details and another is child simple product .But importance thing is that both case sku of two row is same and it is simple sku. As it save two rows,Then you can easily get:

  1. Simple and configurable data at any times using **product_id**
  2. It help for coupon apply.
  3. Sales Report
  4. Another,when configurable item c in art you can get simple product image

But in visible of order item only show those item whose parent_item_id is null.Thus you can only show configurable product details in order.

Simple product is related to configurable item using item_id

enter image description here

Related Topic