Skip to content

Commit 9f93334

Browse files
committed
ACP2E-172: Error adding configurable product to cart using GraphQL directly after storeview is changed
1 parent f649184 commit 9f93334

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
8787
throw new GraphQlNoSuchEntityException(__('The cart isn\'t active.'));
8888
}
8989

90-
$this->updateCartCurrency($cart, $storeId);
90+
$cart = $this->updateCartCurrency($cart, $storeId);
9191

9292
$cartCustomerId = (int)$cart->getCustomerId();
9393

@@ -112,10 +112,11 @@ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
112112
*
113113
* @param Quote $cart
114114
* @param int $storeId
115+
* @return Quote
115116
* @throws GraphQlInputException
116117
* @throws NoSuchEntityException
117118
*/
118-
private function updateCartCurrency(Quote $cart, int $storeId)
119+
private function updateCartCurrency(Quote $cart, int $storeId): Quote
119120
{
120121
$cartStore = $this->storeRepository->getById($cart->getStoreId());
121122
$currentCartCurrencyCode = $cartStore->getCurrentCurrency()->getCode();
@@ -132,8 +133,11 @@ private function updateCartCurrency(Quote $cart, int $storeId)
132133
} elseif ($cart->getQuoteCurrencyCode() !== $currentCartCurrencyCode) {
133134
$cart->setQuoteCurrencyCode($cartStore->getCurrentCurrency());
134135
} else {
135-
return;
136+
return $cart;
136137
}
137138
$this->cartRepository->save($cart);
139+
$cart = $this->cartRepository->get($cart->getId());
140+
141+
return $cart;
138142
}
139143
}

0 commit comments

Comments
 (0)