Skip to content

Commit b2ee65e

Browse files
author
Stanislav Idolov
committed
MAGETWO-53464: Reorder not load products
1 parent 81955af commit b2ee65e

File tree

4 files changed

+16
-25
lines changed

4 files changed

+16
-25
lines changed

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,16 @@ public function __construct(
150150
*/
151151
public function getQuote()
152152
{
153-
$cartManagement = $this->getCartManagement();
154-
155153
if ($this->_quote === null) {
154+
$this->_quote = $this->quoteFactory->create();
156155
if ($this->getStoreId()) {
157156
if (!$this->getQuoteId()) {
158-
$this->setQuoteId($cartManagement->createEmptyCart());
159-
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
160157
$this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId());
161-
$this->_quote->setIsActive(false);
158+
$this->_quote->setStoreId($this->getStoreId());
159+
160+
$this->quoteRepository->save($this->_quote);
161+
$this->setQuoteId($this->_quote->getId());
162+
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
162163
} else {
163164
$this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]);
164165
$this->_quote->setStoreId($this->getStoreId());
@@ -167,6 +168,7 @@ public function getQuote()
167168
if ($this->getCustomerId() && $this->getCustomerId() != $this->_quote->getCustomerId()) {
168169
$customer = $this->customerRepository->getById($this->getCustomerId());
169170
$this->_quote->assignCustomer($customer);
171+
$this->quoteRepository->save($this->_quote);
170172
}
171173
}
172174
$this->_quote->setIgnoreOldQty(true);
@@ -176,18 +178,6 @@ public function getQuote()
176178
return $this->_quote;
177179
}
178180

179-
/**
180-
* @return CartManagementInterface
181-
* @deprecated
182-
*/
183-
private function getCartManagement()
184-
{
185-
if ($this->cartManagement === null) {
186-
$this->cartManagement = ObjectManager::getInstance()->get(CartManagementInterface::class);
187-
}
188-
return $this->cartManagement;
189-
}
190-
191181
/**
192182
* Retrieve store model object
193183
*

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ public function getItemsCollection()
564564
public function getAllItems()
565565
{
566566
// We calculate item list once and cache it in three arrays - all items
567-
$cachedItems = 'all';
568-
$key = 'cached_items_' . $cachedItems;
567+
$key = 'cached_items_all';
569568
if (!$this->hasData($key)) {
570569
$quoteItems = $this->getQuote()->getItemsCollection();
571570
$addressItems = $this->getItemsCollection();

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,12 @@ public function save(\Magento\Quote\Api\Data\CartInterface $quote)
150150
{
151151
if ($quote->getId()) {
152152
$currentQuote = $this->get($quote->getId(), [$quote->getStoreId()]);
153-
$currentQuote->setStoreId($quote->getStoreId());
154-
// This part has to be refactored
155-
if ($quote->getBillingAddress()) {
156-
$currentQuote->setBillingAddress($quote->getBillingAddress());
153+
154+
foreach ($currentQuote->getData() as $key => $value) {
155+
if ($quote->getData($key) === null) {
156+
$quote->setData($key, $value);
157+
}
157158
}
158-
$currentQuote->addData($quote->getData());
159-
$quote = $currentQuote;
160159
}
161160

162161
$this->getSaveHandler()->save($quote);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ public function initFromOrder(\Magento\Sales\Model\Order $order)
552552
$this->collectRates();
553553
}
554554

555+
$quote->getShippingAddress()->unsCachedItemsAll();
556+
$quote->setTotalsCollectedFlag(false);
557+
555558
$this->quoteRepository->save($quote);
556559

557560
return $this;

0 commit comments

Comments
 (0)