Skip to content

Commit 70d27fa

Browse files
committed
B2B-2224: Reduce session storage utilization in GraphQL by removing session in Magento\DirectoryGraphQl\Controller\HttpHeaderProcessor\CurrencyProcessor
1 parent 708f583 commit 70d27fa

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

app/code/Magento/DirectoryGraphQl/Controller/HttpHeaderProcessor/CurrencyProcessor.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ public function processHeaderValue(string $headerValue) : void
6868
try {
6969
$currentStore = $this->storeManager->getStore();
7070
$defaultCode = $currentStore->getDefaultCurrency()->getCode();
71-
if (!empty($headerValue)) {
72-
$headerCurrency = strtoupper(ltrim(rtrim($headerValue)));
73-
if (!in_array($headerCurrency, $currentStore->getAvailableCurrencyCodes(true))) {
74-
//skip store not found exception as it will be handled in graphql validation
75-
$this->logger->warning(__('Currency not allowed for store %1', [$currentStore->getCode()]));
76-
}
77-
$this->httpContext->setValue(HttpContext::CONTEXT_CURRENCY, $headerCurrency, $defaultCode);
78-
} else {
71+
if (empty($headerValue)) {
7972
$this->httpContext->setValue(
8073
HttpContext::CONTEXT_CURRENCY,
8174
$currentStore->getCurrentCurrency()->getCode(),
8275
$defaultCode
8376
);
77+
} else {
78+
$headerCurrency = strtoupper(trim($headerValue));
79+
if (!in_array($headerCurrency, $currentStore->getAvailableCurrencyCodes(true))) {
80+
//skip store not found exception as it will be handled in graphql validation
81+
$this->logger->warning(__('Currency not allowed for store %1', [$currentStore->getCode()]));
82+
}
83+
$this->httpContext->setValue(HttpContext::CONTEXT_CURRENCY, $headerCurrency, $defaultCode);
8484
}
8585
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
8686
//skip store not found exception as it will be handled in graphql validation

0 commit comments

Comments
 (0)