UpdateShippingTablerate.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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\OfflineShipping\Setup\Patch\Data;
  8. use Magento\Framework\Setup\Patch\DataPatchInterface;
  9. use Magento\OfflineShipping\Model\Carrier\Tablerate;
  10. /**
  11. * Update for shipping_tablerate table for using price with discount in condition.
  12. */
  13. class UpdateShippingTablerate implements DataPatchInterface
  14. {
  15. /**
  16. * @var \Magento\Framework\Setup\ModuleDataSetupInterface
  17. */
  18. private $moduleDataSetup;
  19. /**
  20. * PatchInitial constructor.
  21. * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
  22. */
  23. public function __construct(
  24. \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
  25. ) {
  26. $this->moduleDataSetup = $moduleDataSetup;
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function apply()
  32. {
  33. $this->moduleDataSetup->getConnection()->startSetup();
  34. $connection = $this->moduleDataSetup->getConnection();
  35. $connection->update(
  36. $this->moduleDataSetup->getTable('shipping_tablerate'),
  37. ['condition_name' => 'package_value_with_discount'],
  38. [new \Zend_Db_Expr('condition_name = \'package_value\'')]
  39. );
  40. $connection->update(
  41. $this->moduleDataSetup->getTable('core_config_data'),
  42. ['value' => 'package_value_with_discount'],
  43. [
  44. new \Zend_Db_Expr('value = \'package_value\''),
  45. new \Zend_Db_Expr('path = \'carriers/tablerate/condition_name\'')
  46. ]
  47. );
  48. $this->moduleDataSetup->getConnection()->endSetup();
  49. $connection->endSetup();
  50. }
  51. /**
  52. * @inheritdoc
  53. */
  54. public static function getDependencies()
  55. {
  56. return [];
  57. }
  58. /**
  59. * @inheritdoc
  60. */
  61. public function getAliases()
  62. {
  63. return [];
  64. }
  65. }