Skip to content

magento/magento2#24468: Export Coupon Code Grid redirect to DashBoard… #24608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,12 @@ protected function _prepareColumns()
['header' => __('Times Used'), 'index' => 'times_used', 'width' => '50', 'type' => 'number']
);

$this->addExportType('*/*/exportCouponsCsv', __('CSV'));
$this->addExportType('*/*/exportCouponsXml', __('Excel XML'));
$priceRule = $this->_coreRegistry->registry(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE);

if($priceRule && $priceRule->getId()) {
$this->addExportType('*/*/exportCouponsCsv', __('CSV'));
$this->addExportType('*/*/exportCouponsXml', __('Excel XML'));
}
return parent::_prepareColumns();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;

use Exception;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ResponseInterface;

/**
* Class ExportCouponsCsv
* @package Magento\SalesRule\Controller\Adminhtml\Promo\Quote
*/
class ExportCouponsCsv extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
{
/**
* Export coupon codes as CSV file
*
* @return \Magento\Framework\App\ResponseInterface|null
* @return ResponseInterface|null|void
* @throws Exception
*/
public function execute()
{
Expand All @@ -26,7 +32,7 @@ public function execute()
)->getCsvFile();
return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
} else {
$this->_redirect('sales_rule/*/detail', ['_current' => true]);
$this->_redirect('sales_rule/*/edit', ['_current' => true]);
return;
}
}
Expand Down