magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

India lists only 1 region, it appears to use an odd file AddRegionsForIndia.php #39102

Closed devchris79 closed 2 days ago

devchris79 commented 2 months ago

Preconditions and environment

Steps to reproduce

Select India, only 1 region appears - Ladakh

Expected result

Multiple regions displayed

Actual result

1 region appears - Ladakh

Additional information

It appears that a selection of India is using app/code/Magento/Directory/Setup/Patch/Data/AddRegionsForIndia.php I assume it should be using app/code/Magento/Directory/Setup/Patch/Data/AddDataForIndia.php (file also exists in same directory) as every other country appears to use this format. India appears to be some odd exception...

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 months ago

Hi @devchris79. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 2 months ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

devchris79 commented 2 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 months ago

Hi @devchris79. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 months ago

Hi @devchris79, here is your Magento Instance: https://425b33c70d326c1b721c9944d897ac48.instances-prod.magento-community.engineering Admin access: https://425b33c70d326c1b721c9944d897ac48.instances-prod.magento-community.engineering/admin_70cf Login: 60720acc Password: 7c09f3d9d112

devchris79 commented 2 months ago

The development instance doesn't show the issue, India has the regions in the shipping options. I wonder if its an issue when updating an instance of Magento.

engcom-Bravo commented 2 months ago

Hi @devchris79,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is not reproducible.Multiple regions displayed

Screenshot 2024-08-26 at 11 49 14

Could you please let us know from which version you have upgraded the instance and facing this issue.

Thanks.

devchris79 commented 2 months ago

Magento was updated from version 2.4.6 to 2.4.7, although the issue could have been present prior to that. I have manually injected regions into the database to correct for now.

@glo17720 (file author) Why is there two very similar files for adding regions to India, AddRegionsForIndia.php looks wrong with only Ladakh in the array as seen in our 2.4.7 site, where as AddDataForIndia.php looks correct.

engcom-Bravo commented 3 weeks ago

Hi @devchris79,

Thanks for your update.

We are moving this issue On hold as we are discussing this issue with the Internal Team.

Thanks

engcom-Bravo commented 2 days ago

Hi @devchris79,

We got reply from the internal team as follows :

In Magento 2, data patches are applied during bin/magento setup:upgrade. When a new data patch is added, Magento checks the patch_list table to see if it’s already applied. If not, it applies the patch.

If you modify an existing patch, it won’t reapply automatically. To reapply, you must delete the patch’s entry in patch_list or create a new patch file for additional changes.

The file AddDataForIndia.php is a data patch file that is applied once during installation.

To reapply the data patch with the newly added Ladakh region in the AddDataForIndia.php file, follow these steps:

Remove the entry for the AddDataForIndia patch from the patch_list table.

   SET SQL_SAFE_UPDATES = 0;
   DELETE FROM <root-directory-name>.patch_list WHERE patch_name = 'Magento\\Directory\\Setup\\Patch\\Data\\AddDataForIndia';

Delete the corresponding regions associated with India (to avoid duplicate regions when the patch is reapplied) from the directory_country_region table.

DELETE FROM <root-directory-name>.directory_country_region WHERE country_id = 'IN';
   SET SQL_SAFE_UPDATES = 1;

Note: Being in production, deleting directly from SQL is not recommended.

This will force Magento to reapply the patch.

To avoid these steps, a new data patch, AddRegionsForIndia, has been added with the new region, Ladakh. This patch will be applied without affecting existing data.

Below are screen recordings of regions in versions 2.4.6 and 2.4.7, showing that regions are unaffected after upgrading from 2.4.6 to 2.4.7.

https://github.com/user-attachments/assets/9bd5abf5-0979-4dda-98d4-76499122fc00

https://github.com/user-attachments/assets/25c2ddc2-b442-49df-91ae-c0d3bce3cab8

verified it by upgrading from 2.4.6 to 2.4.7. Issue is not reproducible.Hence we are closing this issue.

Thank