Split quote item for Backorder quantity #41
Description
I am trying to use your Module to separate the products that are ordered in backorders mode.
I ask you if you know the most correct method to separate the same Item Quote into two different orders, with the quantities divided by backorders.
Ex:
Product 1 -> Stock = Qty: 3, Min_Qty: -10(Out-of-Stock Threshold)
Custumer Cart: Product 1 -> Qty: 8
So 3 real Stock and 5 Backorders
i want 2 orders:
Order 1: Product 1 -> Qty: 3
Order 2: Product 1 -> Qty: 5
Now i've modified (in Magestat/SplitOrder/Model/ExtensionAttributes.php) your function quantityAndStockStatus
if ($this->helperData->getBackorder() && ($attributes->getStockItem()->getQty() - $item->getQty() < 0) ) { return 'out'; }
So i can get if Quote Item have Backorders.
Then in normalizeQuote function:
if($attribute === 'out'){
$qtyIn = $product->getExtensionAttributes()->getStockItem()->getQty();
$qtyOut = $item->getQty() - $qtyIn;
$itemCopy = clone $item;
$groups["in"][] = $item->setQty($qtyIn);
$this->writeLog("getQty() before > " . $item->getQty() );
$groups[$attribute][] = $itemCopy->setQty($qtyOut);
$this->writeLog("itemCopy() after > " . $itemCopy->getQty() );
$item->save();
$itemCopy->save();
} else {
$groups[$attribute][] = $item;
}
Additional context
Now the order is split correctly but tax_amount for the 2 Quotes isn't changed and the Stock statud of Product 1 is set -8 quantity so the stockInventory decurted 3 more quantity than the orders placed.
I did a lot of research and found nothing about dividing the same Item into two orders.
Have you any suggestion or feature to implement?