|
7 | 7 |
|
8 | 8 | namespace Magento\Sales\Setup\Patch\Data;
|
9 | 9 |
|
| 10 | +use Magento\Framework\DB\Adapter\Pdo\Mysql; |
10 | 11 | use Magento\Framework\Setup\ModuleDataSetupInterface;
|
11 | 12 | use Magento\Framework\Setup\Patch\DataPatchInterface;
|
12 | 13 | use Magento\Framework\Setup\Patch\PatchVersionInterface;
|
| 14 | +use Magento\Sales\Setup\SalesSetup; |
13 | 15 | use Magento\Sales\Setup\SalesSetupFactory;
|
14 | 16 |
|
15 | 17 | /**
|
@@ -44,16 +46,16 @@ public function __construct(
|
44 | 46 | */
|
45 | 47 | public function apply()
|
46 | 48 | {
|
| 49 | + /** @var SalesSetup $salesSetup */ |
47 | 50 | $salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
|
| 51 | + /** @var Mysql $connection */ |
48 | 52 | $connection = $salesSetup->getConnection();
|
49 | 53 | $creditMemoGridTable = $salesSetup->getTable('sales_creditmemo_grid');
|
50 | 54 | $orderTable = $salesSetup->getTable('sales_order');
|
51 |
| - // phpcs:disable Magento2.SQL.RawQuery |
52 |
| - $sql = "UPDATE {$creditMemoGridTable} AS scg |
53 |
| - JOIN {$orderTable} AS so ON so.entity_id = scg.order_id |
54 |
| - SET scg.order_currency_code = so.order_currency_code, |
55 |
| - scg.base_currency_code = so.base_currency_code;"; |
56 |
| - |
| 55 | + $select = $connection->select(); |
| 56 | + $condition = 'so.entity_id = scg.order_id'; |
| 57 | + $select->join(['so' => $orderTable], $condition, ['order_currency_code', 'base_currency_code']); |
| 58 | + $sql = $connection->updateFromSelect($select, ['scg' => $creditMemoGridTable]); |
57 | 59 | $connection->query($sql);
|
58 | 60 | }
|
59 | 61 |
|
|
0 commit comments