Skip to content

Commit 145c7b2

Browse files
author
Roman Lytvynenko
committed
MC-18094: Full page cache issue with non-default store view
1 parent dc2e73a commit 145c7b2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

app/code/Magento/Store/App/Action/Plugin/Context.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Exception\NotFoundException;
1212
use Magento\Store\Api\Data\StoreInterface;
1313
use Magento\Store\Api\StoreCookieManagerInterface;
14+
use Magento\Store\Model\Store;
1415
use Magento\Store\Model\StoreManagerInterface;
1516
use Magento\Framework\App\Action\AbstractAction;
1617
use Magento\Framework\App\RequestInterface;
@@ -127,14 +128,19 @@ private function processInvalidStoreRequested(
127128
*
128129
* @param StoreInterface $store
129130
* @return void
131+
* @throws \Magento\Framework\Exception\LocalizedException
130132
*/
131133
private function updateContext(StoreInterface $store)
132134
{
133-
$this->httpContext->setValue(
134-
StoreManagerInterface::CONTEXT_STORE,
135-
$store->getCode(),
136-
$this->storeManager->getDefaultStoreView()->getCode()
137-
);
135+
if (!$store->getConfig(Store::XML_PATH_STORE_IN_URL) ||
136+
$store->getId() == $this->storeManager->getDefaultStoreView()->getId()
137+
) {
138+
$this->httpContext->setValue(
139+
StoreManagerInterface::CONTEXT_STORE,
140+
$store->getCode(),
141+
$this->storeManager->getDefaultStoreView()->getCode()
142+
);
143+
}
138144

139145
/** @var StoreInterface $defaultStore */
140146
$defaultStore = $this->storeManager->getWebsite()->getDefaultStore();

0 commit comments

Comments
 (0)