Closed prabhuram93 closed 4 years ago
@joni-jones @kokoc @paliarush @akaplya @buskamuza
Approved???
What data would actually be stored in the text field? The complete rule data for each sales rule? That could end up growing rather quickly. In that case we might be better off having another table like salesrule_revision_history (or make salesrule immutable and hide replaced versions) which we can reference by id.
Alternatively if we are not looking to recalculate the rule we should be able to only save the calculated results like actual discount and tax amounts and labels.
Problem
The individual itemized break down of the discounts applied at cart and cart item level are to be computed and persisted on every order.
Solution
Existing Implementation
The itemized discounts are computed and stored with extension attributes on Magento\Quote\Api\Data\CartItemInterface Magento\Quote\Api\Data\AddressInterface. These are served via GraphQL cart query. The eventual end goal is to persist this data on every order.
Schema changes
The existing discount related metadata are being stored in quote_address, quote_item, sales_order, sales_order_item. But these tables tend to get large and have millions of records, and is decided its not ideal to alter heavyweight tables. So new tables have to be created to hold discounts data.
Also have to be cognizant about avoiding referencing between sales and quote tables.
The data will be stored as serialized json to support extensibility.
quote_totals
sales_order_totals
Benefits
Need to modify current table structure to incorporate this feature. Will support extensibility in the future to store additional data pertaining to totals, without modifying the table.
Requested Reviewers
@joni-jones @kokoc @paliarush @akaplya