While playing around with product backodering system in In-Commerce I've noticed few issues.
We're collecting IDs of orders, that were changed in Admin Console to attempt to their reserve items. Unfortunately these IDs are not being reset, when we're done editing resulting in item reservation happening for all previously edited orders, when another order is saved.
To fix this the following variable needs to be removed from session in
When item reservation happen we're always adding qty to the
QtyBackordered columns of the product/product option combination. This way when saving order 5 times you'll get 5x qty reserved/backordered of what you're planning to get.
To fix this we need to create
recalculateInventory(array $product_ids) method, that will:
- get all records from
OrderItemstable, where given products are being used
- calculate Products.QtyReserved column as
- calculate Products.QtyBackordered column as
SUM(IF(OrderItems.BackorderFlag = 1, OrderItems.QuantityReserved - OrderItems.Quantity, 0))
- in all places, where we manipulate with
QtyInStock, QtyReserved, QtyBackOrderedcolumns of product/product order combination we need to use this new method instead
Implementing proposed fix won't be possible until [In-Commerce] Don't mix QtyInStock and QtyReserved fields in product [5.2.1] is implemented.