Skip to content

Commit 18a6653

Browse files
committed
pull request 22123: Fix database compare test
1 parent 3142776 commit 18a6653

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Setup\Patch\Data;
9+
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Framework\Setup\Patch\DataPatchInterface;
12+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
13+
use Magento\Sales\Setup\SalesSetupFactory;
14+
15+
class UpdateCreditmemoGridCurrencyCode implements DataPatchInterface, PatchVersionInterface
16+
{
17+
/**
18+
* @var ModuleDataSetupInterface
19+
*/
20+
private $moduleDataSetup;
21+
22+
/**
23+
* @var SalesSetupFactory
24+
*/
25+
private $salesSetupFactory;
26+
27+
/**
28+
* @param ModuleDataSetupInterface $moduleDataSetup
29+
* @param SalesSetupFactory $salesSetupFactory
30+
*/
31+
public function __construct(
32+
ModuleDataSetupInterface $moduleDataSetup,
33+
SalesSetupFactory $salesSetupFactory
34+
) {
35+
$this->moduleDataSetup = $moduleDataSetup;
36+
$this->salesSetupFactory = $salesSetupFactory;
37+
}
38+
39+
/**
40+
* @inheritdoc
41+
*/
42+
public function apply()
43+
{
44+
$salesSetup = $this->salesSetupFactory->create(['setup' => $this->moduleDataSetup]);
45+
$connection = $salesSetup->getConnection();
46+
$creditMemoGridTable = $salesSetup->getTable('sales_creditmemo_grid');
47+
$orderTable = $salesSetup->getTable('sales_order');
48+
49+
$sql = "UPDATE {$creditMemoGridTable} AS scg
50+
JOIN {$orderTable} AS so ON so.entity_id = scg.order_id
51+
SET scg.order_currency_code = so.order_currency_code,
52+
scg.base_currency_code = so.base_currency_code;";
53+
54+
$connection->query($sql);
55+
}
56+
57+
/**
58+
* @inheritdoc
59+
*/
60+
public static function getDependencies()
61+
{
62+
return [];
63+
}
64+
65+
/**
66+
* @inheritdoc
67+
*/
68+
public static function getVersion()
69+
{
70+
return '2.0.13';
71+
}
72+
73+
/**
74+
* @inheritdoc
75+
*/
76+
public function getAliases()
77+
{
78+
return [];
79+
}
80+
}

0 commit comments

Comments
 (0)