-
Type: Bug Report
-
Status: New
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Data Management
-
Labels:None
-
Story Points:2
-
Copy Issue Key:
-
Patch Instructions:
Create recalculateInventory(array $product_ids) method, that will:
- get all records from OrderItems table, where given products are being used
- calculate Products.QtyReserved column as SUM(OrderItems.QuantityReserved)
- calculate Products.QtyBackordered column as SUM(IF(OrderItems.BackorderFlag = 1, OrderItems.QuantityReserved - OrderItems.Quantity, 0))
- in all places, where we manipulate with QtyInStock, QtyReserved, QtyBackOrdered columns of product/product order combination we need to use this new method instead
Same applies to product option combinations table.
This cover index would be very helpful to speed up SQL:
ALTER TABLE OrderItems ADD INDEX IX_PRODUCT_INVENTORY_COVER (ProductId, QuantityReserved, BackOrderFlag, Quantity);