storeid와 국가명 불러오기

storeID 구하기

1
2
3
4
5
6
7
8
9
10
11
public function (
MagentoStoreModelStoreManagerInterface $storeManager,
)
{
$this->_storeManager = $storeManager;
}
public function getStoreId()
{
return $this->_storeManager->getStore()->getId();
}

위와 같이 생성자에 선언 후

1
2
3
4
public function execute()
{
$storeId = $this->getStoreId();
}

위와 같이 사용하면 된다. $storeId에 저장된다.


countryName 구하기

1
2
3
4
5
6
7
8
public function (
MagentoDirectoryApiCountryInformationAcquirerInterface $countryInformation,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
)
{
$this->countryInformation = $countryInformation;
$this->scopeConfig = $scopeConfig;
}

마찬가지로 위의 2개를 생성자에 호출해준다.

1
2
3
4
5
public function execute()
{
$countryInfo = $this->countryInformation->getCountryInfo($country);
$countryName = $countryInfo->getFullNameLocale();
}

필요한 부분에서 저런 식으로 호출하면 언어에 맞는 국가명을 호출할 수 있다.


참 쉽죠?