Child pages
  • [in-commerce] Issues with product reservation/backorder [5.2.1]
Skip to end of metadata
Go to start of metadata

While playing around with product backodering system in In-Commerce I've noticed few issues.

Issue #1

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 OnPreCreate and OnEdit events: 

$event->Prefix . '_copied_ids' . $this->Application->GetVar('wid')

Issue #2

When item reservation happen we're always adding qty to the QtyReserved and 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:

  1. get all records from OrderItems table, where given products are being used
  2. calculate Products.QtyReserved column as SUM(OrderItems.QuantityReserved)
  3. calculate Products.QtyBackordered column as SUM(IF(OrderItems.BackorderFlag = 1, OrderItems.QuantityReserved - OrderItems.Quantity, 0))
  4. in all places, where we manipulate with QtyInStock, QtyReserved, QtyBackOrdered columns 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.

Related Tasks

MINC-114 - Getting issue details... STATUS

MINC-116 - Getting issue details... STATUS