Skip to content

Commit 43a568e

Browse files
committed
Merge remote-tracking branch 'origin/imported-magento-magento2-31553' into 2.4-develop-pr120
2 parents d5d5372 + 8417b88 commit 43a568e

File tree

6 files changed

+152
-4
lines changed

6 files changed

+152
-4
lines changed

app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Grid/Collection.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,32 @@ public function __construct(
3333
) {
3434
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
3535
}
36+
37+
/**
38+
* @inheritDoc
39+
*/
40+
protected function _translateCondition($field, $condition)
41+
{
42+
if ($field !== 'order_currency_code'
43+
&& !isset($this->_map['fields'][$field])
44+
) {
45+
$this->_map['fields'][$field] = 'main_table.' . $field;
46+
}
47+
48+
return parent::_translateCondition($field, $condition);
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
protected function _renderFiltersBefore()
55+
{
56+
$this->getSelect()->joinLeft(
57+
['cgf' => $this->getTable('sales_order_grid')],
58+
'main_table.order_id = cgf.entity_id',
59+
[
60+
'order_currency_code' => 'order_currency_code',
61+
]
62+
);
63+
}
3664
}

app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo/Order/Grid/Collection.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,32 @@ public function __construct(
3333
) {
3434
parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);
3535
}
36+
37+
/**
38+
* @inheritDoc
39+
*/
40+
protected function _translateCondition($field, $condition)
41+
{
42+
if ($field !== 'order_currency_code'
43+
&& !isset($this->_map['fields'][$field])
44+
) {
45+
$this->_map['fields'][$field] = 'main_table.' . $field;
46+
}
47+
48+
return parent::_translateCondition($field, $condition);
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
protected function _renderFiltersBefore()
55+
{
56+
$this->getSelect()->joinLeft(
57+
['cgf' => $this->getTable('sales_order_grid')],
58+
'main_table.order_id = cgf.entity_id',
59+
[
60+
'order_currency_code' => 'order_currency_code',
61+
]
62+
);
63+
}
3664
}

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_creditmemo_grid.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,14 @@
194194
<visible>false</visible>
195195
</settings>
196196
</column>
197-
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price">
197+
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
198198
<settings>
199199
<filter>textRange</filter>
200200
<label translate="true">Subtotal</label>
201201
<visible>false</visible>
202202
</settings>
203203
</column>
204-
<column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price">
204+
<column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
205205
<settings>
206206
<filter>textRange</filter>
207207
<label translate="true">Shipping &amp; Handling</label>

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_view_creditmemo_grid.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@
207207
<visible>false</visible>
208208
</settings>
209209
</column>
210-
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\Price">
210+
<column name="subtotal" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
211211
<settings>
212212
<filter>textRange</filter>
213213
<label translate="true">Subtotal</label>
214214
<visible>false</visible>
215215
</settings>
216216
</column>
217-
<column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\Price">
217+
<column name="shipping_and_handling" class="Magento\Sales\Ui\Component\Listing\Column\PurchasedPrice">
218218
<settings>
219219
<filter>textRange</filter>
220220
<label translate="true">Shipping &amp; Handling</label>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\Model\ResourceModel\Order\Creditmemo\Grid;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use PHPUnit\Framework\TestCase;
13+
14+
/**
15+
* Test Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid
16+
*/
17+
class CollectionTest extends TestCase
18+
{
19+
/**
20+
* @var ObjectManagerInterface
21+
*/
22+
private $objectManager;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function setUp(): void
28+
{
29+
$this->objectManager = Bootstrap::getObjectManager();
30+
}
31+
32+
/**
33+
* @magentoDataFixture Magento/Sales/_files/creditmemo_list.php
34+
*
35+
* @return void
36+
*/
37+
public function testCollectionOrderCurrencyCodeExist(): void
38+
{
39+
/** @var $collection Collection */
40+
$collection = $this->objectManager->get(Collection::class);
41+
$collection->addFieldToFilter('increment_id', ['eq' => '456']);
42+
foreach ($collection as $item) {
43+
$this->assertNotNull($item->getOrderCurrencyCode());
44+
}
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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\Model\ResourceModel\Order\Creditmemo\Order\Grid;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
use PHPUnit\Framework\TestCase;
13+
14+
/**
15+
* Test Magento\Sales\Model\ResourceModel\Order\Creditmemo\Grid\Order\Grid
16+
*/
17+
class CollectionTest extends TestCase
18+
{
19+
/**
20+
* @var ObjectManagerInterface
21+
*/
22+
private $objectManager;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function setUp(): void
28+
{
29+
$this->objectManager = Bootstrap::getObjectManager();
30+
}
31+
32+
/**
33+
* @magentoDataFixture Magento/Sales/_files/creditmemo_list.php
34+
*
35+
* @return void
36+
*/
37+
public function testCollectionOrderCurrencyCodeExist(): void
38+
{
39+
/** @var $collection Collection */
40+
$collection = $this->objectManager->get(Collection::class);
41+
$collection->addFieldToFilter('increment_id', ['eq' => '456']);
42+
foreach ($collection as $item) {
43+
$this->assertNotNull($item->getOrderCurrencyCode());
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)