Skip to content

Commit ff6a42f

Browse files
committed
ACP2E-1482: Upload Path for Export Option in Magento's Reports Section
1 parent d48a739 commit ff6a42f

File tree

4 files changed

+68
-8
lines changed

4 files changed

+68
-8
lines changed

app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsCsv.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
89

10+
use Magento\Framework\App\Filesystem\DirectoryList;
911
use Magento\Framework\App\ResponseInterface;
12+
use Magento\Reports\Controller\Adminhtml\Report\Product;
1013

11-
class ExportDownloadsCsv extends \Magento\Reports\Controller\Adminhtml\Report\Product
14+
/**
15+
* Exporting list of product in CVS format.
16+
*
17+
* @SuppressWarnings(PHPMD.AllPurposeAction)
18+
*/
19+
class ExportDownloadsCsv extends Product
1220
{
1321
/**
1422
* Authorization level of a basic admin session
1523
*
1624
* @see _isAllowed()
1725
*/
18-
const ADMIN_RESOURCE = 'Magento_Reports::report_products';
26+
public const ADMIN_RESOURCE = 'Magento_Reports::report_products';
1927

2028
/**
2129
* Export products downloads report to CSV format
@@ -31,6 +39,6 @@ public function execute()
3139
true
3240
)->getCsv();
3341

34-
return $this->_fileFactory->create($fileName, $content);
42+
return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
3543
}
3644
}

app/code/Magento/Reports/Controller/Adminhtml/Report/Product/ExportDownloadsExcel.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
6+
declare(strict_types=1);
7+
78
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
89

10+
use Magento\Framework\App\Filesystem\DirectoryList;
911
use Magento\Framework\App\ResponseInterface;
12+
use Magento\Reports\Controller\Adminhtml\Report\Product;
1013

11-
class ExportDownloadsExcel extends \Magento\Reports\Controller\Adminhtml\Report\Product
14+
/**
15+
* Exporting list of product in Excel format.
16+
*
17+
* @SuppressWarnings(PHPMD.AllPurposeAction)
18+
*/
19+
class ExportDownloadsExcel extends Product
1220
{
1321
/**
1422
* Authorization level of a basic admin session
1523
*
1624
* @see _isAllowed()
1725
*/
18-
const ADMIN_RESOURCE = 'Magento_Reports::report_products';
26+
public const ADMIN_RESOURCE = 'Magento_Reports::report_products';
1927

2028
/**
2129
* Export products downloads report to XLS format
@@ -33,6 +41,6 @@ public function execute()
3341
$fileName
3442
);
3543

36-
return $this->_fileFactory->create($fileName, $content);
44+
return $this->_fileFactory->create($fileName, $content, DirectoryList::VAR_DIR);
3745
}
3846
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\Reports\Test\Integration\Controller\Adminhtml\Report\Product;
9+
10+
use Magento\TestFramework\TestCase\AbstractBackendController;
11+
12+
/**
13+
* @magentoAppArea adminhtml
14+
*/
15+
class ExportDownloadsCsvTest extends AbstractBackendController
16+
{
17+
public function testExecute()
18+
{
19+
$this->dispatch('backend/reports/report_product/exportDownloadsCsv');
20+
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\Reports\Test\Integration\Controller\Adminhtml\Report\Product;
9+
10+
use Magento\TestFramework\TestCase\AbstractBackendController;
11+
12+
/**
13+
* @magentoAppArea adminhtml
14+
*/
15+
class ExportDownloadsExcelTest extends AbstractBackendController
16+
{
17+
public function testExecute()
18+
{
19+
$this->dispatch('backend/reports/report_product/exportDownloadsExcel');
20+
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
21+
}
22+
}

0 commit comments

Comments
 (0)