Skip to content

Commit 0c90778

Browse files
authored
ENGCOM-3578: Fix: SalesQuoteSaveAfterObserver fails to update the checkout session quote id when applicable #19425
2 parents 8c13cb0 + ca75474 commit 0c90778

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

app/code/Magento/Checkout/Observer/SalesQuoteSaveAfterObserver.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Framework\Event\ObserverInterface;
99

10+
/**
11+
* Class SalesQuoteSaveAfterObserver
12+
*/
1013
class SalesQuoteSaveAfterObserver implements ObserverInterface
1114
{
1215
/**
@@ -24,15 +27,18 @@ public function __construct(\Magento\Checkout\Model\Session $checkoutSession)
2427
}
2528

2629
/**
30+
* Assign quote to session
31+
*
2732
* @param \Magento\Framework\Event\Observer $observer
2833
* @return void
2934
*/
3035
public function execute(\Magento\Framework\Event\Observer $observer)
3136
{
37+
/* @var \Magento\Quote\Model\Quote $quote */
3238
$quote = $observer->getEvent()->getQuote();
33-
/* @var $quote \Magento\Quote\Model\Quote */
39+
3440
if ($quote->getIsCheckoutCart()) {
35-
$this->checkoutSession->getQuoteId($quote->getId());
41+
$this->checkoutSession->setQuoteId($quote->getId());
3642
}
3743
}
3844
}

app/code/Magento/Checkout/Test/Unit/Observer/SalesQuoteSaveAfterObserverTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ protected function setUp()
3030

3131
public function testSalesQuoteSaveAfter()
3232
{
33+
$quoteId = 7;
3334
$observer = $this->createMock(\Magento\Framework\Event\Observer::class);
3435
$observer->expects($this->once())->method('getEvent')->will(
3536
$this->returnValue(new \Magento\Framework\DataObject(
36-
['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => 7])]
37+
['quote' => new \Magento\Framework\DataObject(['is_checkout_cart' => 1, 'id' => $quoteId])]
3738
))
3839
);
39-
$this->checkoutSession->expects($this->once())->method('getQuoteId')->with(7);
40+
$this->checkoutSession->expects($this->once())->method('setQuoteId')->with($quoteId);
4041

4142
$this->object->execute($observer);
4243
}

0 commit comments

Comments
 (0)