Skip to content

Commit 052d0cc

Browse files
MAGETWO-95773: Credit memo is created instead of returning error via invoice refund API for Bundle product
- add error message for incorrect product items
1 parent 77af5d6 commit 052d0cc

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Item/Validation/CreationQuantityValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public function validate($entity)
5353
return [__('The creditmemo contains product item that is not part of the original order.')];
5454
}
5555

56+
if ($orderItem->isDummy()) {
57+
return [__('The creditmemo contains incorrect product items.')];
58+
}
59+
5660
if (!$this->isQtyAvailable($orderItem, $entity->getQty())) {
5761
return [__('The quantity to refund must not be greater than the unrefunded quantity.')];
5862
}

app/code/Magento/Sales/Model/Order/ItemRepository.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ private function addParentItem(OrderItemInterface $orderItem)
228228
{
229229
if ($parentId = $orderItem->getParentItemId()) {
230230
$orderItem->setParentItem($this->get($parentId));
231+
} else {
232+
foreach ($orderItem->getOrder()->getAllItems() as $item) {
233+
if($item->getParentItemId() === $orderItem->getItemId()) {
234+
$item->setParentItem($orderItem);
235+
}
236+
}
231237
}
232238
}
233239

0 commit comments

Comments
 (0)