Magento: get region list for country in admin shipping module

Magento: get region list for country in admin shipping module

July 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: get region list for country in admin shipping module

Optimizing Magento’s Region Selection for Administrative Shipping

As an experienced e-commerce developer working extensively with Magento, I often encounter requests to streamline the admin panel experience. One common challenge is managing the extensive list of regions (states or counties) within the shipping module configuration. In this post, we’ll explore how to optimize your region selection process by filtering results based on the chosen country.

Current Multi-Select Approach

Currently, you can pull through a complete list of regions using the following XML snippet in your system.xml file:

<counties translate="label">
    <label>Counties</label>
    <frontend_type>multiselect</frontend_type>
    <sort_order>10</sort_order>
    <source_model>adminhtml/system_config_source_allregion</source_model>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</counties>

While this works for displaying all available regions, it can become overwhelming when you’ve added a large number of them to the system.

Filtering Regions for a Specific Country

To address this issue and improve user experience, we want to filter the region list based on the selected country. Here’s how you can achieve this:

  1. Copy and modify the source model file

First, duplicate the app/code/core/Mage/Adminhtml/Model/System/Config/Source/Allregion.php file and rename it as Ukregion.php (or any other relevant name).

  1. Update the class definition

Change the class definition in the newly created file to match its new name:

class Mage_Adminhtml_Model_System_Config_Source_Ukregion extends Mage_Core_Model_Abstract
{
    ...
}
  1. Filter regions based on country code

Modify the region collection initialization within your getAllOptions() method as follows:

$regionsCollection = Mage::getResourceModel('directory/region_collection')
    ->addCountryFilter('GB')  // Add country filter here
    ->load();

In this example, ‘GB’ represents the country code for the United Kingdom. You can replace it with any desired country code.

  1. Update your system.xml file

Finally, update your system.xml configuration to use the new source model:

<counties translate="label">
    <label>Counties</label>
    <frontend_type>multiselect</frontend_type>
    <sort_order>10</sort_order>
    <source_model>adminhtml/system_config_source_ukregion</source_model>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
</counties>

Conclusion

By following these steps, you’ll successfully filter the region list within your Magento admin panel to display only the relevant options for a selected country. This approach significantly improves user experience by providing a more manageable selection process.

Remember that this is just one example; you can apply the same logic to any desired country by changing the country code in step 3 and updating the source model name accordingly.

For further guidance on optimizing your e-commerce platform, feel free to explore other resources available at Laravel Company. We provide expert insights and practical solutions for developers working with various technologies in the digital commerce landscape.

Performance Extensions Admin Configuration

Our network