Skip to content

Commit 22edbb9

Browse files
committed
Revert "Customer related values are NULL for guests"
This reverts commit ccba420
1 parent b9f72f7 commit 22edbb9

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

app/code/Magento/Store/Model/Store.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,10 +1169,6 @@ public function getCurrentUrl($fromStore = true)
11691169

11701170
$storeUrl = $this->getUrl('', ['_secure' => $this->_storeManager->getStore()->isCurrentlySecure()]);
11711171

1172-
if ($this->_config->getValue(self::XML_PATH_STORE_IN_URL)) {
1173-
$storeUrl = preg_replace('/\/'.$this->getCode().'{1}/','',$storeUrl);
1174-
}
1175-
11761172
if (!filter_var($storeUrl, FILTER_VALIDATE_URL)) {
11771173
return $storeUrl;
11781174
}

app/code/Magento/Store/Url/Plugin/RouteParamsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function beforeSetRouteParams(
7878
$storeCode
7979
);
8080

81-
if ($useStoreInUrl && !$this->storeManager->hasSingleStore()) {
81+
if (!$useStoreInUrl && !$this->storeManager->hasSingleStore()) {
8282
$this->queryParamsResolver->setQueryParam('___store', $storeCode);
8383
}
8484
}

dev/tests/integration/testsuite/Magento/Store/Model/StoreTest.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
namespace Magento\Store\Model;
88

9+
use Magento\Catalog\Model\ProductRepository;
910
use Magento\Framework\App\Bootstrap;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
1012
use Magento\Framework\App\Filesystem\DirectoryList;
1113
use Magento\Framework\UrlInterface;
14+
use Magento\Store\Api\StoreRepositoryInterface;
1215
use Zend\Stdlib\Parameters;
1316

1417
/**
@@ -268,23 +271,33 @@ public function testIsCanDelete()
268271
}
269272

270273
/**
271-
* @magentoDataFixture Magento/Store/_files/second_store.php
274+
* @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php
275+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
276+
* @magentoDbIsolation disabled
272277
*/
273278
public function testGetCurrentUrl()
274279
{
280+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
281+
$objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
282+
->setValue('web/url/use_store', true, ScopeInterface::SCOPE_STORE, 'secondstore');
283+
275284
$this->model->load('admin');
276285
$this->model->expects($this->any())->method('getUrl')->will($this->returnValue('http://localhost/index.php'));
277286
$this->assertStringEndsWith('default', $this->model->getCurrentUrl());
278287
$this->assertStringEndsNotWith('default', $this->model->getCurrentUrl(false));
279288

280-
$this->model->load('fixture_second_store');
289+
/** @var \Magento\Store\Model\Store $secondStore */
290+
$secondStore = $objectManager->get(StoreRepositoryInterface::class)->get('secondstore');
281291

282-
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
283-
->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
284-
->setValue(Store::XML_PATH_STORE_IN_URL, true, ScopeInterface::SCOPE_STORE);
285-
286-
$this->assertEquals('http://localhost/index.php?___store=fixture_second_store&___from_store=default', $this->model->getCurrentUrl(true));
287-
$this->assertEquals('http://localhost/index.php?___store=fixture_second_store', $this->model->getCurrentUrl(false));
292+
/** @var \Magento\Catalog\Model\ProductRepository $productRepository */
293+
$productRepository = $objectManager->create(ProductRepository::class);
294+
$product = $productRepository->get('simple');
295+
$product->setStoreId($secondStore->getId());
296+
$url = $product->getUrlInStore();
297+
298+
$this->assertEquals('http://localhost/index.php/secondstore/catalog/product/view/id/1/s/simple-product/', $url);
299+
$this->assertEquals('http://localhost/index.php/secondstore/?___from_store=default', $secondStore->getCurrentUrl());
300+
$this->assertEquals('http://localhost/index.php/secondstore/', $secondStore->getCurrentUrl(false));
288301
}
289302

290303
/**

0 commit comments

Comments
 (0)