Skip to content

Commit

Permalink
magento#12714 - pass parameter for export button url
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay-wagento committed Jan 16, 2018
1 parent 8848d94 commit f7baf29
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
<listingToolbar name="listing_top">
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<exportButton name="export_button"/>
<exportButton name="export_button">
<settings>
<additionalParams>
<param xsi:type="string" active="true" name="order_id">*</param>
</additionalParams>
</settings>
</exportButton>
<filterSearch name="fulltext"/>
<filters name="listing_filters">
<filterSelect name="store_id" provider="${ $.parentName }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
<listingToolbar name="listing_top">
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<exportButton name="export_button"/>
<exportButton name="export_button">
<settings>
<additionalParams>
<param xsi:type="string" active="true" name="order_id">*</param>
</additionalParams>
</settings>
</exportButton>
<filterSearch name="fulltext"/>
<filters name="listing_filters">
<filterSelect name="store_id" provider="${ $.parentName }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
<listingToolbar name="listing_top">
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<exportButton name="export_button"/>
<exportButton name="export_button">
<settings>
<additionalParams>
<param xsi:type="string" active="true" name="order_id">*</param>
</additionalParams>
</settings>
</exportButton>
<filterSearch name="fulltext"/>
<filters name="listing_filters">
<filterSelect name="store_id" provider="${ $.parentName }">
Expand Down
25 changes: 24 additions & 1 deletion app/code/Magento/Ui/Component/ExportButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,39 @@ public function getComponentName()
*/
public function prepare()
{
$context = $this->getContext();
$config = $this->getData('config');
if (isset($config['options'])) {
$options = [];
foreach ($config['options'] as $option) {
$option['url'] = $this->urlBuilder->getUrl($option['url']);
$additionalParams = $this->getAdditionalParams($config, $context);
$option['url'] = $this->urlBuilder->getUrl($option['url'], $additionalParams);
$options[] = $option;
}
$config['options'] = $options;
$this->setData('config', $config);
}
parent::prepare();
}

/**
* Get export button additional parameters
*
* @param array $config
* @param ContextInterface $context
* @return array
*/
protected function getAdditionalParams($config, $context)
{
$additionalParams = [];
if (isset($config['additionalParams'])) {
foreach ($config['additionalParams'] as $paramName => $paramValue) {
if ('*' == $paramValue) {
$paramValue = $context->getRequestParam($paramName);
}
$additionalParams[$paramName] = $paramValue;
}
}
return $additionalParams;
}
}

0 comments on commit f7baf29

Please sign in to comment.