0

I am new in Magento2.3. I want to create a Drop down for states for Italy country.

In Magento1 we have used below code:

INSERT INTO  `magento1.6`.`directory_country_region` (
`region_id` ,
`country_id` ,
`code` ,
`default_name`
)
VALUES (
'0',  'IN',  'IN-DL',  'New Delhi'
);

What is the code in Magento2?

0

Magento 2 directory_country_region table is the same with magento 1. You can use same SQL to add Italy states:

INSERT INTO  `magento2.3`.`directory_country_region` (
`country_id` ,
`code`,
`default_name`
)
VALUES ('IT',  'Rome',  'Rome');

We don't need region_id because it is auto increasement.

Please note that same state name can be added multiple times so if you run insert query more than once, you will end up with something like this:

enter image description here

If this happens, you can go to your database and remove the dupplicated entries.

2
0

In Magento 2 you can enable state options in backend of your shop login in Magento backend and go to tab

Store->General->General you will see state options you have to enable that for Italy and clear cache

enter image description here

bin/magento clear:cache
1
  • yes its correct but i want to add these using schema.php how can i do that – maeneo Mar 19 '20 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.