I wrote a section in UpgradeData.php to insert and delete some values in tables directory_country_region_name
and directory_country_region
. Code below,
if (version_compare($context->getVersion(), "1.0.6", "<")) {
$connection = $setup->getConnection();
$disallowed = implode(',',[6,7,8,9,10,11,17,30,50]);
$caFrLocalization = array(array('fr_CA',66,'Alberta'),
array('fr_CA',67,'Colombie-Britannique'),
array('fr_CA',68,'Manitoba'),
array('fr_CA',69,'Terre-Neuve-et-Labrador'),
array('fr_CA',70,'Nouveau-Brunswick'),
array('fr_CA',71,'Nouvelle-Écosse'),
array('fr_CA',72,'Territoires du Nord-Ouest'),
array('fr_CA',73,'Nunavut'),
array('fr_CA',74,'Ontario'),
array('fr_CA',75,'Île-du-Prince-Édouard'),
array('fr_CA',76,'Québec'),
array('fr_CA',77,'Saskatchewan'),
array('fr_CA',78,'Yukon'));
// Add Canadian localized regions
$connection->insertArray($connection->getTableName('directory_country_region_name'),array('locale', 'region_id', 'name'),$caFrLocalization);
// Remove extra US states
$connection->delete($connection->getTableName('directory_country_region_name'),['region_id IN (?)'=>$disallowed]);
$connection->delete($connection->getTableName('directory_country_region'),['region_id IN (?)'=>$disallowed]);
}
And module.xml
,
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Project_Ecommerce" setup_version="1.0.7"/>
</config>
When I deploy this to the local Magento environment the changes are made as expected.
However when I deploy to the Magento Cloud I do not see the results of this code executing.
This is the script I use to deploy these changes to Magento Local,
rm -rf var/di var/generation
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_CA fr_CA -f
php bin/magento weltpixel:less:generate
php bin/magento cache:flush
sudo chmod 777 var/cache
On the Magento Cloud I just deploy the changes with a git push
.