Skip to content

Commit fcfe4da

Browse files
committed
ACP2E-3618: [CLOUD] Re-order button functionality
1 parent 3f12d15 commit fcfe4da

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

app/code/Magento/Quote/Model/Quote.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
namespace Magento\Quote\Model;
77

@@ -1699,23 +1699,12 @@ public function addProduct(
16991699

17001700
$this->itemProcessor->prepare($item, $request, $candidate);
17011701

1702-
// collect errors instead of throwing first one
17031702
if ($item->getHasError()) {
17041703
if (!$invalidProductAddFlag) {
17051704
$this->deleteItem($item);
17061705
}
1707-
foreach ($item->getMessage(false) as $message) {
1708-
if (!in_array($message, $errors)) {
1709-
// filter duplicate messages
1710-
$errors[] = $message;
1711-
}
1712-
}
1713-
break;
17141706
}
17151707
}
1716-
if (!empty($errors)) {
1717-
throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors)));
1718-
}
17191708

17201709
$this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]);
17211710
return $parentItem;

app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Reorder.php

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -130,4 +130,28 @@ public function execute()
130130

131131
return $resultRedirect;
132132
}
133+
134+
/**
135+
* Collect all item errors
136+
*
137+
* @param $order
138+
* @return array
139+
*/
140+
private function getItemErrors($order): array
141+
{
142+
$errors = [];
143+
$items = $order->getAllItems();
144+
foreach($items as $item) {
145+
if (!$item->getMessage(false)) {
146+
continue;
147+
}
148+
foreach ($item->getMessage(false) as $message) {
149+
if (!in_array($message, $errors)) {
150+
$errors[] = $message;
151+
}
152+
}
153+
}
154+
155+
return $errors;
156+
}
133157
}

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,11 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
598598
if (is_string($item)) {
599599
throw new \Magento\Framework\Exception\LocalizedException(__($item));
600600
}
601+
if ($item->getStockStateResult() && $item->getStockStateResult()->getHasError()) {
602+
$this->messageManager->addErrorMessage(
603+
__('The product with SKU %sku is out of stock.', ['sku' => $item->getSku()])
604+
);
605+
}
601606
}
602607
}
603608
}

0 commit comments

Comments
 (0)