Commit 30925dc7 authored by Ángel Campos's avatar Ángel Campos Committed by GitHub

[PW-2128]: Migration script for setting terminal_selection based on pos_store_id (#669)

* [PW-2128]: Migration script for setting terminal_selection based on pos_store_id

* [PW-2128]: Changing module version to 6.0.0-alpha1
* This enables dev and testing instances to upgrade from version 5 and still remain below 6.0.0
parent c80a0332
......@@ -66,6 +66,10 @@ class UpgradeData implements UpgradeDataInterface
$this->updateSchemaVersion244($setup);
}
if (version_compare($context->getVersion(), '6.0.0', '<')) {
$this->updateDataVersion600($setup);
}
$setup->endSetup();
}
......@@ -158,4 +162,58 @@ class UpgradeData implements UpgradeDataInterface
// re-initialize otherwise it will cause errors
$this->reinitableConfig->reinit();
}
/**
* Upgrade to 6.0.0
* The new configuration UI uses new fields, combines selections that used
* to be separated and splits old fields into multiple configurations
*
* @param ModuleDataSetupInterface $setup
*/
public function updateDataVersion600(ModuleDataSetupInterface $setup)
{
$pathTerminalSelection = "payment/adyen_pos_cloud/terminal_selection";
$pathPosStoreId = "payment/adyen_pos_cloud/pos_store_id";
$configDataTable = $setup->getTable('core_config_data');
$connection = $setup->getConnection();
//Setting terminal_selection=store_level for scopes that have pos_store_id set
$select = $connection->select()
->from($configDataTable)
->where('path = ?', $pathPosStoreId)
->where('value <> "" AND value IS NOT NULL');
$configPosStoreIdValues = $connection->fetchAll($select);
foreach ($configPosStoreIdValues as $configPosStoreIdValue) {
$scope = $configPosStoreIdValue['scope'];
$scopeId = $configPosStoreIdValue['scope_id'];
$this->configWriter->save(
$pathTerminalSelection,
'store_level',
$scope,
$scopeId
);
}
//Setting terminal_selection=merchant_account_level for scopes where pos_store_id is empty
$select = $connection->select()
->from($configDataTable)
->where('path = ?', $pathPosStoreId)
->where('value = ""');
$configPosStoreIdEmptyValues = $connection->fetchAll($select);
foreach ($configPosStoreIdEmptyValues as $configPosStoreIdEmptyValue) {
$scopeEmpty = $configPosStoreIdEmptyValue['scope'];
$scopeIdEmpty = $configPosStoreIdEmptyValue['scope_id'];
$this->configWriter->save(
$pathTerminalSelection,
'merchant_account_level',
$scopeEmpty,
$scopeIdEmpty
);
}
$this->reinitableConfig->reinit();
}
}
......@@ -155,6 +155,7 @@
<total_timeout>120</total_timeout>
<recurring_type>NONE</recurring_type>
<group>adyen</group>
<terminal_selection>merchant_account_level</terminal_selection>
</adyen_pos_cloud>
<adyen_pay_by_mail>
<active>0</active>
......
......@@ -24,7 +24,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="5.4.0">
<module name="Adyen_Payment" setup_version="6.0.0-alpha1">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment