Skip to content

Commit 66968b9

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-35161' of https://github.com/magento-mpi/magento2ce into TANGO-PR-09-01-2020_24
2 parents e1c5c1d + 605d211 commit 66968b9

File tree

2 files changed

+12
-13
lines changed
  • app/code/Magento/Sales/Model/AdminOrder
  • dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder

2 files changed

+12
-13
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,12 @@ public function getCustomerCart()
745745
try {
746746
$this->_cart = $this->quoteRepository->getForCustomer($customerId, [$storeId]);
747747
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
748-
$this->_cart->setStore($this->getSession()->getStore());
749-
$customerData = $this->customerRepository->getById($customerId);
750-
$this->_cart->assignCustomer($customerData);
751-
$this->quoteRepository->save($this->_cart);
748+
if ($this->getQuote()->hasItems()) {
749+
$this->_cart->setStore($this->getSession()->getStore());
750+
$customerData = $this->customerRepository->getById($customerId);
751+
$this->_cart->assignCustomer($customerData);
752+
$this->quoteRepository->save($this->_cart);
753+
}
752754
}
753755
}
754756

@@ -785,6 +787,7 @@ public function getCustomerCompareList()
785787
public function getCustomerGroupId()
786788
{
787789
$groupId = $this->getQuote()->getCustomerGroupId();
790+
// @phpstan-ignore-next-line
788791
if (!isset($groupId)) {
789792
$groupId = $this->getSession()->getCustomerGroupId();
790793
}
@@ -1443,9 +1446,10 @@ public function setShippingAddress($address)
14431446
*/
14441447
$saveInAddressBook = (int)(!empty($address['save_in_address_book']));
14451448
$shippingAddress->setData('save_in_address_book', $saveInAddressBook);
1446-
}
1447-
if ($address instanceof \Magento\Quote\Model\Quote\Address) {
1449+
} elseif ($address instanceof \Magento\Quote\Model\Quote\Address) {
14481450
$shippingAddress = $address;
1451+
} else {
1452+
$shippingAddress = null;
14491453
}
14501454

14511455
$this->setRecollect(true);

dev/tests/integration/testsuite/Magento/Sales/Model/AdminOrder/CreateTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ public function testMoveQuoteItemToCart()
684684
public function testGetCustomerCartNewCart()
685685
{
686686
$customerIdFromFixture = 1;
687-
$customerEmailFromFixture = 'customer@example.com';
688687

689688
/** Preconditions */
690689
/** @var SessionQuote $session */
@@ -693,12 +692,8 @@ public function testGetCustomerCartNewCart()
693692

694693
/** SUT execution */
695694
$customerQuote = $this->model->getCustomerCart();
696-
self::assertNotEmpty($customerQuote->getId(), 'Quote ID is invalid.');
697-
self::assertEquals(
698-
$customerEmailFromFixture,
699-
$customerQuote->getCustomerEmail(),
700-
'Customer data is preserved incorrectly in a newly quote.'
701-
);
695+
self::assertInstanceOf(Quote::class, $customerQuote);
696+
self::assertEmpty($customerQuote->getData());
702697
}
703698

704699
/**

0 commit comments

Comments
 (0)