Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning

We strongly recommend create database backup before you make any changes!

Check on the staging story store copy first!


Panel
bgColor#fff
  1. Prepare SQL script to add necessary states to the directory_country_region and directory_country_region_name  tables. Here is an example for Norway: 

    Code Block
    languagesql
    INSERT INTO `directory_country_region` (`region_id`, `country_id`, `code`, `default_name`) VALUES
    (NULL, 'NO', '01', 'Østfold'),
    (NULL, 'NO', '02', 'Akershus'),
    (NULL, 'NO', '03', 'Oslo'),
    (NULL, 'NO', '04', 'Hedmark'),
    (NULL, 'NO', '05', 'Oppland'),
    (NULL, 'NO', '06', 'Buskerud'),
    (NULL, 'NO', '07', 'Vestfold'),
    (NULL, 'NO', '08', 'Telemark')
    ;
    
    
    INSERT INTO directory_country_region_name( locale, region_id, name )
    SELECT 'en_US' AS "language", region_id, default_name
    FROM `directory_country_region`
    WHERE country_id = 'NO';
    
    INSERT INTO directory_country_region_name( locale, region_id, name )
    SELECT 'en_US' AS "language", region_id, default_name
    FROM `directory_country_region`
    WHERE country_id = 'nb_NO';
    
    INSERT INTO directory_country_region_name( locale, region_id, name )
    SELECT 'en_US' AS "language", region_id, default_name
    FROM `directory_country_region`
    WHERE country_id = 'nn_NO';


  2. Prepare SQL queries to update address tables. Here is an example for Norway country

    Code Block
    languagesql
    UPDATE customer_address_entity
    SET region_id = (SELECT region_id
    FROM directory_country_region
    WHERE directory_country_region.default_name = customer_address_entity.region
    AND directory_country_region.country_id = customer_address_entity.country_id
    )
    WHERE (region_id = 0 or ISNULL(region_id))
    AND country_id = 'NO';
    
    
    UPDATE sales_order_address
    SET region_id = (SELECT region_id
    FROM directory_country_region
    WHERE directory_country_region.default_name = sales_order_address.region
    AND directory_country_region.country_id = sales_order_address.country_id
    )
    WHERE (region_id = 0 or ISNULL(region_id))
    AND country_id = 'NO';
    
    UPDATE quote_address
    SET region_id = (SELECT region_id
    FROM directory_country_region
    WHERE directory_country_region.default_name = quote_address.region
    AND directory_country_region.country_id = quote_address.country_id
    )
    WHERE (region_id = 0 or ISNULL(region_id))
    AND country_id = 'NO';
    


  3. Apply these patches on your staging installation first.

...