Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExportCouponsXml.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
18  public function execute()
19  {
20  $this->_initRule();
21  $rule = $this->_coreRegistry->registry(\Magento\SalesRule\Model\RegistryConstants::CURRENT_SALES_RULE);
22  if ($rule->getId()) {
23  $fileName = 'coupon_codes.xml';
24  $content = $this->_view->getLayout()->createBlock(
25  \Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Grid::class
26  )->getExcelFile(
27  $fileName
28  );
29  return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
30  } else {
31  $this->_redirect('sales_rule/*/detail', ['_current' => true]);
32  return;
33  }
34  }
35 }
$fileName
Definition: translate.phtml:15