Skip to content

Commit b4e3113

Browse files
author
Marcel Moldovan
committed
🐛 Fix not detecting current store using store code in url
Use $storeManager->getStore()->getId() instead of $storeResolver->getCurrentStoreId()
1 parent 9dd7c72 commit b4e3113

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Checkout\Block\Checkout;
77

88
use Magento\Directory\Helper\Data as DirectoryHelper;
9-
use Magento\Store\Api\StoreResolverInterface;
9+
use Magento\Store\Model\StoreManagerInterface;
1010

1111
/**
1212
* Directory data processor.
@@ -37,9 +37,9 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
3737
private $countryCollectionFactory;
3838

3939
/**
40-
* @var StoreResolverInterface
40+
* @var StoreManagerInterface
4141
*/
42-
private $storeResolver;
42+
private $storeManager;
4343

4444
/**
4545
* @var DirectoryHelper
@@ -49,18 +49,18 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
4949
/**
5050
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
5151
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
52-
* @param StoreResolverInterface $storeResolver
52+
* @param StoreManagerInterface $storeManager
5353
* @param DirectoryHelper $directoryHelper
5454
*/
5555
public function __construct(
5656
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
5757
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
58-
StoreResolverInterface $storeResolver,
58+
StoreManagerInterface $storeManager,
5959
DirectoryHelper $directoryHelper
6060
) {
6161
$this->countryCollectionFactory = $countryCollection;
6262
$this->regionCollectionFactory = $regionCollection;
63-
$this->storeResolver = $storeResolver;
63+
$this->storeManager = $storeManager;
6464
$this->directoryHelper = $directoryHelper;
6565
}
6666

@@ -91,7 +91,7 @@ private function getCountryOptions()
9191
{
9292
if (!isset($this->countryOptions)) {
9393
$this->countryOptions = $this->countryCollectionFactory->create()->loadByStore(
94-
$this->storeResolver->getCurrentStoreId()
94+
$this->storeManager->getStore()->getId()
9595
)->toOptionArray();
9696
$this->countryOptions = $this->orderCountryOptions($this->countryOptions);
9797
}
@@ -108,7 +108,7 @@ private function getRegionOptions()
108108
{
109109
if (!isset($this->regionOptions)) {
110110
$this->regionOptions = $this->regionCollectionFactory->create()->addAllowedCountriesFilter(
111-
$this->storeResolver->getCurrentStoreId()
111+
$this->storeManager->getStore()->getId()
112112
)->toOptionArray();
113113
}
114114

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
*/
1212
namespace Magento\Customer\Model\ResourceModel\Address\Attribute\Source;
1313

14-
use Magento\Checkout\Model\Session;
1514
use Magento\Framework\App\ObjectManager;
16-
use Magento\Store\Api\StoreResolverInterface;
1715
use Magento\Store\Model\StoreManagerInterface;
1816

1917
/**
@@ -28,9 +26,9 @@ class Country extends \Magento\Eav\Model\Entity\Attribute\Source\Table
2826
protected $_countriesFactory;
2927

3028
/**
31-
* @var StoreResolverInterface
29+
* @var StoreManagerInterface
3230
*/
33-
private $storeResolver;
31+
private $storeManager;
3432

3533
/**
3634
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
@@ -55,7 +53,7 @@ public function getAllOptions()
5553
{
5654
if (!$this->_options) {
5755
$this->_options = $this->_createCountriesCollection()->loadByStore(
58-
$this->getStoreResolver()->getCurrentStoreId()
56+
$this->getStoreManager()->getStore()->getId()
5957
)->toOptionArray();
6058
}
6159
return $this->_options;
@@ -70,16 +68,16 @@ protected function _createCountriesCollection()
7068
}
7169

7270
/**
73-
* Retrieve Store Resolver
71+
* Retrieve Store Manager
7472
* @deprecated
75-
* @return StoreResolverInterface
73+
* @return StoreManagerInterface
7674
*/
77-
private function getStoreResolver()
75+
private function getStoreManager()
7876
{
79-
if (!$this->storeResolver) {
80-
$this->storeResolver = ObjectManager::getInstance()->get(StoreResolverInterface::class);
77+
if (!$this->storeManager) {
78+
$this->storeManager = ObjectManager::getInstance()->get(StoreManagerInterface::class);
8179
}
8280

83-
return $this->storeResolver;
81+
return $this->storeManager;
8482
}
8583
}

0 commit comments

Comments
 (0)