Reading list Switch to dark mode

    Get Region Id By Region Code Magento 2

    Updated 6 January 2023

    Get Region Id By Region Code Magento 2 : If you need region id by region code. check the below code.

    $regionCode = 'CA';
    $countryCode = 'US';
    $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
    
    $region = $objectManager->create('Magento\Directory\Model\Region');
    
    $regionId = $region->loadByCode($regionCode, $countryCode)->getId();

    here $regionId contains the region id.

    hope so it will help.

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home