SalesQuoteSaveAfterObserver.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Observer;
  7. use Magento\Framework\Event\ObserverInterface;
  8. /**
  9. * Class SalesQuoteSaveAfterObserver
  10. */
  11. class SalesQuoteSaveAfterObserver implements ObserverInterface
  12. {
  13. /**
  14. * @var \Magento\Checkout\Model\Session
  15. */
  16. protected $checkoutSession;
  17. /**
  18. * @param \Magento\Checkout\Model\Session $checkoutSession
  19. * @codeCoverageIgnore
  20. */
  21. public function __construct(\Magento\Checkout\Model\Session $checkoutSession)
  22. {
  23. $this->checkoutSession = $checkoutSession;
  24. }
  25. /**
  26. * Assign quote to session
  27. *
  28. * @param \Magento\Framework\Event\Observer $observer
  29. * @return void
  30. */
  31. public function execute(\Magento\Framework\Event\Observer $observer)
  32. {
  33. /* @var \Magento\Quote\Model\Quote $quote */
  34. $quote = $observer->getEvent()->getQuote();
  35. if ($quote->getIsCheckoutCart()) {
  36. $this->checkoutSession->setQuoteId($quote->getId());
  37. }
  38. }
  39. }