|
6 | 6 |
|
7 | 7 | namespace Magento\Usps\Setup;
|
8 | 8 |
|
9 |
| -use Magento\Framework\Setup\InstallDataInterface; |
10 | 9 | use Magento\Framework\Setup\ModuleContextInterface;
|
11 | 10 | use Magento\Framework\Setup\ModuleDataSetupInterface;
|
| 11 | +use Magento\Framework\Setup\UpgradeDataInterface; |
12 | 12 |
|
13 |
| -/** |
14 |
| - * @codeCoverageIgnore |
15 |
| - */ |
16 |
| -class InstallData implements InstallDataInterface |
| 13 | +class UpgradeData implements UpgradeDataInterface |
17 | 14 | {
|
18 | 15 | /**
|
19 |
| - * {@inheritdoc} |
| 16 | + * @inheritdoc |
| 17 | + */ |
| 18 | + public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) |
| 19 | + { |
| 20 | + if (version_compare($context->getVersion(), '2.0.1', '<')) { |
| 21 | + $this->updateAllowedMethods($setup); |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Replaces titles of allowed shipping methods to their codes. |
| 27 | + * |
| 28 | + * @param ModuleDataSetupInterface $setup |
| 29 | + * @return void |
20 | 30 | */
|
21 |
| - public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) |
| 31 | + private function updateAllowedMethods(ModuleDataSetupInterface $setup) |
22 | 32 | {
|
23 | 33 | $installer = $setup;
|
24 | 34 | $configDataTable = $installer->getTable('core_config_data');
|
@@ -69,12 +79,12 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
|
69 | 79 | 'Priority Mail International Large Flat Rate Box' => 'INT_11',
|
70 | 80 | ];
|
71 | 81 |
|
72 |
| - $select = $connection->select()->from( |
73 |
| - $configDataTable |
74 |
| - )->where( |
75 |
| - 'path IN (?)', |
76 |
| - ['carriers/usps/free_method', 'carriers/usps/allowed_methods'] |
77 |
| - ); |
| 82 | + $select = $connection->select() |
| 83 | + ->from($configDataTable) |
| 84 | + ->where( |
| 85 | + 'path IN (?)', |
| 86 | + ['carriers/usps/free_method', 'carriers/usps/allowed_methods'] |
| 87 | + ); |
78 | 88 | $oldConfigValues = $connection->fetchAll($select);
|
79 | 89 |
|
80 | 90 | foreach ($oldConfigValues as $oldValue) {
|
|
0 commit comments