Skip to content

Commit

Permalink
ENGCOM-3976: [Backport] issue #18349 Fixed for 2.3: Incorrect quote_i…
Browse files Browse the repository at this point in the history
…tem_id saved on order items during multiple address checkout #20640
  • Loading branch information
sidolov authored Feb 8, 2019
2 parents 26d6f3e + 27bd987 commit 19560b9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ private function removePlacedItemsFromQuote(array $shippingAddresses, array $pla
{
foreach ($shippingAddresses as $address) {
foreach ($address->getAllItems() as $addressItem) {
if (in_array($addressItem->getId(), $placedAddressItems)) {
if (in_array($addressItem->getQuoteItemId(), $placedAddressItems)) {
if ($addressItem->getProduct()->getIsVirtual()) {
$addressItem->isDeleted(true);
} else {
Expand Down Expand Up @@ -1218,7 +1218,7 @@ private function searchQuoteAddressId(OrderInterface $order, array $addresses):
$item = array_pop($items);
foreach ($addresses as $address) {
foreach ($address->getAllItems() as $addressItem) {
if ($addressItem->getId() == $item->getQuoteItemId()) {
if ($addressItem->getQuoteItemId() == $item->getQuoteItemId()) {
return (int)$address->getId();
}
}
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Quote/Model/Quote/Item/ToOrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public function __construct(
}

/**
* Convert quote item(quote address item) into order item.
*
* @param Item|AddressItem $item
* @param array $data
* @return OrderItemInterface
Expand All @@ -63,6 +65,16 @@ public function convert($item, $data = [])
'to_order_item',
$item
);
if ($item instanceof \Magento\Quote\Model\Quote\Address\Item) {
$orderItemData = array_merge(
$orderItemData,
$this->objectCopyService->getDataFromFieldset(
'quote_convert_address_item',
'to_order_item',
$item
)
);
}
if (!$item->getNoDiscount()) {
$data = array_merge(
$data,
Expand Down
5 changes: 5 additions & 0 deletions app/code/Magento/Quote/etc/fieldset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
<aspect name="to_order_address" />
</field>
</fieldset>
<fieldset id="quote_convert_address_item">
<field name="quote_item_id">
<aspect name="to_order_item" />
</field>
</fieldset>
<fieldset id="quote_convert_item">
<field name="sku">
<aspect name="to_order_item" />
Expand Down

0 comments on commit 19560b9

Please sign in to comment.