UpdatePaypalCreditOption.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Paypal\Setup\Patch\Data;
  8. use Magento\Framework\Setup\ModuleDataSetupInterface;
  9. use Magento\Framework\Setup\Patch\DataPatchInterface;
  10. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  11. /**
  12. * Class AddPaypalOrderStates
  13. */
  14. class UpdatePaypalCreditOption implements DataPatchInterface, PatchVersionInterface
  15. {
  16. /**
  17. * @var ModuleDataSetupInterface
  18. */
  19. private $moduleDataSetup;
  20. /**
  21. * PrepareInitialConfig constructor.
  22. * @param ModuleDataSetupInterface $moduleDataSetup
  23. */
  24. public function __construct(
  25. ModuleDataSetupInterface $moduleDataSetup
  26. ) {
  27. $this->moduleDataSetup = $moduleDataSetup;
  28. }
  29. /**
  30. * @inheritdoc
  31. */
  32. public function apply()
  33. {
  34. $this->moduleDataSetup->getConnection()->startSetup();
  35. $connection = $this->moduleDataSetup->getConnection();
  36. $select = $connection->select()
  37. ->from($this->moduleDataSetup->getTable('core_config_data'), ['scope', 'scope_id', 'value'])
  38. ->where('path = ?', 'payment/paypal_express_bml/active');
  39. foreach ($connection->fetchAll($select) as $pair) {
  40. if (!$pair['value']) {
  41. $this->moduleDataSetup->getConnection()
  42. ->insertOnDuplicate(
  43. $this->moduleDataSetup->getTable('core_config_data'),
  44. [
  45. 'scope' => $pair['scope'],
  46. 'scope_id' => $pair['scope_id'],
  47. 'path' => 'paypal/style/disable_funding_options',
  48. 'value' => 'CREDIT'
  49. ]
  50. );
  51. }
  52. }
  53. $this->moduleDataSetup->getConnection()->endSetup();
  54. }
  55. /**
  56. * @inheritdoc
  57. */
  58. public static function getDependencies()
  59. {
  60. return [];
  61. }
  62. /**
  63. * @inheritdoc
  64. */
  65. public static function getVersion()
  66. {
  67. return '2.3.1';
  68. }
  69. /**
  70. * @inheritdoc
  71. */
  72. public function getAliases()
  73. {
  74. return [];
  75. }
  76. }