Skip to content

Commit 8c05a29

Browse files
⏫ Forwardport of #13208 to 2.3-develop branch
1 parent 8c705bf commit 8c05a29

File tree

5 files changed

+72
-8
lines changed

5 files changed

+72
-8
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
<listingToolbar name="listing_top">
3636
<bookmark name="bookmarks"/>
3737
<columnsControls name="columns_controls"/>
38-
<exportButton name="export_button"/>
38+
<exportButton name="export_button">
39+
<settings>
40+
<additionalParams>
41+
<param xsi:type="string" active="true" name="order_id">*</param>
42+
</additionalParams>
43+
</settings>
44+
</exportButton>
3945
<filterSearch name="fulltext"/>
4046
<filters name="listing_filters">
4147
<filterSelect name="store_id" provider="${ $.parentName }">

app/code/Magento/Ui/Component/ExportButton.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,39 @@ public function getComponentName()
5454
*/
5555
public function prepare()
5656
{
57+
$context = $this->getContext();
5758
$config = $this->getData('config');
5859
if (isset($config['options'])) {
5960
$options = [];
6061
foreach ($config['options'] as $option) {
61-
$option['url'] = $this->urlBuilder->getUrl($option['url']);
62+
$additionalParams = $this->getAdditionalParams($config, $context);
63+
$option['url'] = $this->urlBuilder->getUrl($option['url'], $additionalParams);
6264
$options[] = $option;
6365
}
6466
$config['options'] = $options;
6567
$this->setData('config', $config);
6668
}
6769
parent::prepare();
6870
}
71+
72+
/**
73+
* Get export button additional parameters
74+
*
75+
* @param array $config
76+
* @param ContextInterface $context
77+
* @return array
78+
*/
79+
protected function getAdditionalParams($config, $context)
80+
{
81+
$additionalParams = [];
82+
if (isset($config['additionalParams'])) {
83+
foreach ($config['additionalParams'] as $paramName => $paramValue) {
84+
if ('*' == $paramValue) {
85+
$paramValue = $context->getRequestParam($paramName);
86+
}
87+
$additionalParams[$paramName] = $paramValue;
88+
}
89+
}
90+
return $additionalParams;
91+
}
6992
}

app/code/Magento/Ui/Test/Unit/Component/ExportButtonTest.php

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,37 @@ public function testPrepare()
6262
->disableOriginalConstructor()
6363
->getMock();
6464
$this->context->expects($this->atLeastOnce())->method('getProcessor')->willReturn($processor);
65+
$this->context->expects($this->any())
66+
->method('getRequestParam')
67+
->with('test_asterisk')
68+
->willReturn('test_asterisk_value');
6569
$option = ['label' => 'test label', 'value' => 'test value', 'url' => 'test_url'];
66-
$data = ['config' => ['options' => [$option]]];
70+
$data = [
71+
'config' => [
72+
'options' => [
73+
$option
74+
],
75+
'additionalParams' => [
76+
'test_key' => 'test_value',
77+
'test_asterisk' => '*'
78+
]
79+
],
80+
];
81+
$expected = $data;
82+
$expected['config']['options'][0]['url'] = [
83+
'test_key' => 'test_value',
84+
'test_asterisk' => 'test_asterisk_value',
85+
];
6786
$this->model->setData($data);
68-
6987
$this->urlBuilderMock->expects($this->once())
7088
->method('getUrl')
7189
->with('test_url')
72-
->willReturnArgument(0);
73-
$this->assertNull($this->model->prepare());
90+
->willReturnArgument(1);
91+
92+
self::assertNull($this->model->prepare());
93+
self::assertEquals(
94+
$expected,
95+
$this->model->getData()
96+
);
7497
}
7598
}

0 commit comments

Comments
 (0)