2017 © Pedro Peláez
 

magento2-module m2-module-regionlookup

Magento 2 Region Lookup API

image

navarr/m2-module-regionlookup

Magento 2 Region Lookup API

  • Tuesday, June 6, 2017
  • by navarr
  • Repository
  • 0 Watchers
  • 0 Stars
  • 900 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 2 Versions
  • 17 % Grown

The README.md

RegionInformationAcquirer Service Contract

Installation

This module is really only for developers. You can duplicate it in app/code if for some reason you can't use composer (how would that happen??) or you can just, (*1)

composer require navarr/m2-module-regionlookup

So far this works with all Magento versions, and the composer version constraints are setup so that it won't install if the modules it uses have a breaking change., (*2)

Usage

There are three methods for use, however only two are currently implemented:, (*3)

  • getRegionInfoByCode(string $countryId, string $regionCode) : \Magento\Directory\Api\Data\RegionInformationInterface, throws NoSuchEntityException
  • getRegionInfoByName(string $countryId, string $regionName) : \Magento\Directory\Api\Data\RegionInformationInterface, throws NoSuchEntityException

NoSuchEntityException is thrown when:, (*4)

  • Country ID could not be found
  • Region Name/Code could not be found

A LocalizedException is thrown if you dare to use getRegionInfoById(int $regionId), (*5)

Example

public function __construct(RegionInformationAcquirerInterface $regionAcquirer)
{
    $state = $regionAcquirer->getRegionInfoByCode('US', 'OH');
    $state->getId(); // some number
    $state->getName(); // Ohio
    $state->getCode(); // OH
}

The Versions

06/06 2017

dev-master

9999999-dev

Magento 2 Region Lookup API

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0
  • magento/module-directory ^100.0.2

 

The Development Requires

06/06 2017

1.0.0

1.0.0.0

Magento 2 Region Lookup API

  Sources   Download

MIT

The Requires

  • php ^5.6|^7.0
  • magento/module-directory ^100.0.2

 

The Development Requires