Skip to content

Commit 4bda471

Browse files
committed
fix-patch #22123
1 parent ae304ac commit 4bda471

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

app/code/Magento/Sales/Setup/Patch/Data/UpdateCreditmemoGridCurrencyCode.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77

88
namespace Magento\Sales\Setup\Patch\Data;
99

10+
use Magento\Framework\DB\Adapter\Pdo\Mysql;
1011
use Magento\Framework\Setup\ModuleDataSetupInterface;
1112
use Magento\Framework\Setup\Patch\DataPatchInterface;
1213
use Magento\Framework\Setup\Patch\PatchVersionInterface;
14+
use Magento\Sales\Setup\SalesSetup;
1315
use Magento\Sales\Setup\SalesSetupFactory;
1416

1517
/**
@@ -44,16 +46,16 @@ public function __construct(
4446
*/
4547
public function apply()
4648
{
49+
/** @var SalesSetup $salesSetup */
4750
$salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
51+
/** @var Mysql $connection */
4852
$connection = $salesSetup->getConnection();
4953
$creditMemoGridTable = $salesSetup->getTable('sales_creditmemo_grid');
5054
$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]);
5759
$connection->query($sql);
5860
}
5961

0 commit comments

Comments
 (0)