Skip to content

Commit 37bd1d9

Browse files
committed
AC-11624: Sales reports fix
1 parent b08b7ea commit 37bd1d9

File tree

1 file changed

+20
-26
lines changed
  • app/code/Magento/Reports/Controller/Adminhtml/Report

1 file changed

+20
-26
lines changed

app/code/Magento/Reports/Controller/Adminhtml/Report/Sales.php

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
/**
89
* Sales report admin controller
@@ -13,6 +14,7 @@
1314

1415
/**
1516
* @SuppressWarnings(PHPMD.NumberOfChildren)
17+
* phpcs:disable Magento2.Classes.AbstractApi
1618
* @api
1719
* @since 100.0.2
1820
*/
@@ -37,31 +39,23 @@ public function _initAction()
3739
*/
3840
protected function _isAllowed()
3941
{
40-
switch ($this->getRequest()->getActionName()) {
41-
case 'sales':
42-
return $this->_authorization->isAllowed('Magento_Reports::salesroot_sales');
43-
break;
44-
case 'tax':
45-
return $this->_authorization->isAllowed('Magento_Reports::tax');
46-
break;
47-
case 'shipping':
48-
return $this->_authorization->isAllowed('Magento_Reports::shipping');
49-
break;
50-
case 'invoiced':
51-
return $this->_authorization->isAllowed('Magento_Reports::invoiced');
52-
break;
53-
case 'refunded':
54-
return $this->_authorization->isAllowed('Magento_Reports::refunded');
55-
break;
56-
case 'coupons':
57-
return $this->_authorization->isAllowed('Magento_Reports::coupons');
58-
break;
59-
case 'bestsellers':
60-
return $this->_authorization->isAllowed('Magento_Reports::bestsellers');
61-
break;
62-
default:
63-
return $this->_authorization->isAllowed('Magento_Reports::salesroot');
64-
break;
65-
}
42+
return match (strtolower($this->getRequest()->getActionName())) {
43+
'exportsalescsv', 'exportsalesexcel', 'sales' =>
44+
$this->_authorization->isAllowed('Magento_Reports::salesroot_sales'),
45+
'exporttaxcsv', 'exporttaxexcel', 'tax' =>
46+
$this->_authorization->isAllowed('Magento_Reports::tax'),
47+
'exportshippingcsv', 'exportshippingexcel', 'shipping' =>
48+
$this->_authorization->isAllowed('Magento_Reports::shipping'),
49+
'exportinvoicedcsv', 'exportinvoicedexcel', 'invoiced' =>
50+
$this->_authorization->isAllowed('Magento_Reports::invoiced'),
51+
'exportrefundedcsv', 'exportrefundedexcel', 'refunded' =>
52+
$this->_authorization->isAllowed('Magento_Reports::refunded'),
53+
'exportcouponscsv', 'exportcouponsexcel', 'coupons' =>
54+
$this->_authorization->isAllowed('Magento_Reports::coupons'),
55+
'exportbestsellerscsv', 'exportbestsellersexcel', 'bestsellers' =>
56+
$this->_authorization->isAllowed('Magento_Reports::bestsellers'),
57+
default =>
58+
$this->_authorization->isAllowed('Magento_Reports::salesroot'),
59+
};
6660
}
6761
}

0 commit comments

Comments
 (0)