I'll post ere my problems I am facing while programming extensions for Magento 2.2.
Maybe others have same problems in future, so they may save time I already spent for solving these problems.
order->getShippingAdress()->getCountry() returns NULL instead of country-ISO-Code.
order->getShippingAdress()->getCountryId() works fine
Solved! Go to Solution.
Hi @kornblumenapo,
If I'm not worng that happens becasue the sales_order_address table stores only the country code.
If you want to get the country full data you could use this interface:
Magento\Directory\Api\CountryInformationAcquirerInterface
Then, if you use that interface on your constructor maybe you can get the information with:
/** @var \Magento\Directory\Api\Data\CountryInformationInterface $countryData */ $countryData = $this->countryInformation->getCountryInfo($order->getShippingAddress()->getCountryId());
Now you can use something like:
$countryData->getFullNameLocale() $countryData->getTwoLetterAbbreviation() $countryData->getThreeLetterAbbreviation()
Hi @kornblumenapo,
If I'm not worng that happens becasue the sales_order_address table stores only the country code.
If you want to get the country full data you could use this interface:
Magento\Directory\Api\CountryInformationAcquirerInterface
Then, if you use that interface on your constructor maybe you can get the information with:
/** @var \Magento\Directory\Api\Data\CountryInformationInterface $countryData */ $countryData = $this->countryInformation->getCountryInfo($order->getShippingAddress()->getCountryId());
Now you can use something like:
$countryData->getFullNameLocale() $countryData->getTwoLetterAbbreviation() $countryData->getThreeLetterAbbreviation()