Skip to content

Commit 9d4f9a0

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - #22086: [Backport] Fix eav form foreach error #21134 (by @wojtekn) - #21512: [Backport] Fix: Cart is emptied when enter is pressed after changing product quantity (by @lfluvisotto) - #22037: [Backport] Root exception not logged on QuoteManagement::submitQuote (by @larsroettig) Fixed GitHub Issues: - #21134: Invalid argument supplied for foreach thrown in EAV code (reported by @wojtekn) has been fixed in #22086 by @wojtekn in 2.2-develop branch Related commits: 1. a1d6ed6 2. a7511e0 - #21499: Cart is emptied when enter is pressed after changing product quantity (reported by @wojtekn) has been fixed in #21512 by @lfluvisotto in 2.2-develop branch Related commits: 1. 5a73640 2. f4a83f6 3. 5d0245d - #14926: "Rolled back transaction has not been completed correctly" on Magento 2.2.3 (reported by @Poonika) has been fixed in #22037 by @larsroettig in 2.2-develop branch Related commits: 1. d91acbe 2. 9141077 3. 0168b1f - #18752: Rolled back transaction has not been completed correctly" on Magento 2.1.15 (reported by @adammprost) has been fixed in #22037 by @larsroettig in 2.2-develop branch Related commits: 1. d91acbe 2. 9141077 3. 0168b1f
2 parents 1117583 + 452e823 commit 9d4f9a0

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

app/code/Magento/Checkout/view/frontend/web/js/shopping-cart.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ define([
1414
_create: function () {
1515
var items, i;
1616

17-
$(this.options.emptyCartButton).on('click', $.proxy(function () {
17+
$(this.options.emptyCartButton).on('click', $.proxy(function (event) {
18+
if (event.detail === 0) {
19+
return;
20+
}
21+
1822
$(this.options.emptyCartButton).attr('name', 'update_cart_action_temp');
1923
$(this.options.updateCartActionContainer)
2024
.attr('name', 'update_cart_action').attr('value', 'empty_cart');

app/code/Magento/Eav/Model/Form.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ public function getFormCode()
286286
}
287287

288288
/**
289-
* Return entity type instance
289+
* Return entity type instance.
290+
*
290291
* Return EAV entity type if entity type is not defined
291292
*
292293
* @return \Magento\Eav\Model\Entity\Type
@@ -323,6 +324,8 @@ public function getAttributes()
323324
if ($this->_attributes === null) {
324325
$this->_attributes = [];
325326
$this->_userAttributes = [];
327+
$this->_systemAttributes = [];
328+
$this->_allowedAttributes = [];
326329
/** @var $attribute \Magento\Eav\Model\Attribute */
327330
foreach ($this->_getFilteredFormAttributeCollection() as $attribute) {
328331
$this->_attributes[$attribute->getAttributeCode()] = $attribute;

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

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -529,19 +529,7 @@ protected function submitQuote(QuoteEntity $quote, $orderData = [])
529529
);
530530
$this->quoteRepository->save($quote);
531531
} catch (\Exception $e) {
532-
if (!empty($this->addressesToSync)) {
533-
foreach ($this->addressesToSync as $addressId) {
534-
$this->addressRepository->deleteById($addressId);
535-
}
536-
}
537-
$this->eventManager->dispatch(
538-
'sales_model_service_quote_submit_failure',
539-
[
540-
'order' => $order,
541-
'quote' => $quote,
542-
'exception' => $e
543-
]
544-
);
532+
$this->rollbackAddresses($quote, $order, $e);
545533
throw $e;
546534
}
547535
return $order;
@@ -608,4 +596,41 @@ protected function _prepareCustomerQuote($quote)
608596
$shipping->setIsDefaultBilling(true);
609597
}
610598
}
599+
600+
/**
601+
* Remove related to order and quote addresses and submit exception to further processing.
602+
*
603+
* @param Quote $quote
604+
* @param \Magento\Sales\Api\Data\OrderInterface $order
605+
* @param \Exception $e
606+
* @throws \Exception
607+
*/
608+
private function rollbackAddresses(
609+
QuoteEntity $quote,
610+
\Magento\Sales\Api\Data\OrderInterface $order,
611+
\Exception $e
612+
): void {
613+
try {
614+
if (!empty($this->addressesToSync)) {
615+
foreach ($this->addressesToSync as $addressId) {
616+
$this->addressRepository->deleteById($addressId);
617+
}
618+
}
619+
$this->eventManager->dispatch(
620+
'sales_model_service_quote_submit_failure',
621+
[
622+
'order' => $order,
623+
'quote' => $quote,
624+
'exception' => $e,
625+
]
626+
);
627+
} catch (\Exception $consecutiveException) {
628+
$message = sprintf(
629+
"An exception occurred on 'sales_model_service_quote_submit_failure' event: %s",
630+
$consecutiveException->getMessage()
631+
);
632+
633+
throw new \Exception($message, 0, $e);
634+
}
635+
}
611636
}

0 commit comments

Comments
 (0)