5
5
*/
6
6
namespace Magento \Backend \Helper \Dashboard ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
9
+
8
10
/**
9
11
* Adminhtml dashboard helper for orders
10
12
*
11
13
* @api
12
14
* @since 100.0.2
13
15
*/
14
- class Order extends \ Magento \ Backend \ Helper \ Dashboard \ AbstractDashboard
16
+ class Order extends AbstractDashboard
15
17
{
16
18
/**
17
19
* @var \Magento\Reports\Model\ResourceModel\Order\Collection
18
20
*/
19
- private $ orderCollection ;
21
+ private $ _orderCollection ;
20
22
21
23
/**
22
24
* @var \Magento\Store\Model\StoreManagerInterface
23
25
* @since 100.0.6
24
26
*/
25
- private $ storeManager ;
27
+ private $ _storeManager ;
26
28
27
29
/**
28
30
* @param \Magento\Framework\App\Helper\Context $context
29
31
* @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
32
+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
30
33
*/
31
34
public function __construct (
32
35
\Magento \Framework \App \Helper \Context $ context ,
33
36
\Magento \Reports \Model \ResourceModel \Order \Collection $ orderCollection ,
34
- \Magento \Store \Model \StoreManagerInterface $ storeManager
37
+ \Magento \Store \Model \StoreManagerInterface $ storeManager = null
35
38
) {
36
- $ this ->orderCollection = $ orderCollection ;
37
- $ this ->storeManager = $ storeManager ;
39
+ $ this ->_orderCollection = $ orderCollection ;
40
+ $ this ->_storeManager = $ storeManager ?: ObjectManager::getInstance ()
41
+ ->get (\Magento \Store \Model \StoreManagerInterface::class);
42
+
38
43
parent ::__construct ($ context );
39
44
}
40
45
@@ -48,20 +53,20 @@ protected function _initCollection()
48
53
{
49
54
$ isFilter = $ this ->getParam ('store ' ) || $ this ->getParam ('website ' ) || $ this ->getParam ('group ' );
50
55
51
- $ this ->_collection = $ this ->orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
56
+ $ this ->_collection = $ this ->_orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
52
57
53
58
if ($ this ->getParam ('store ' )) {
54
59
$ this ->_collection ->addFieldToFilter ('store_id ' , $ this ->getParam ('store ' ));
55
60
} elseif ($ this ->getParam ('website ' )) {
56
- $ storeIds = $ this ->storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
61
+ $ storeIds = $ this ->_storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
57
62
$ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
58
63
} elseif ($ this ->getParam ('group ' )) {
59
- $ storeIds = $ this ->storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
64
+ $ storeIds = $ this ->_storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
60
65
$ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
61
66
} elseif (!$ this ->_collection ->isLive ()) {
62
67
$ this ->_collection ->addFieldToFilter (
63
68
'store_id ' ,
64
- ['eq ' => $ this ->storeManager ->getStore (\Magento \Store \Model \Store::ADMIN_CODE )->getId ()]
69
+ ['eq ' => $ this ->_storeManager ->getStore (\Magento \Store \Model \Store::ADMIN_CODE )->getId ()]
65
70
);
66
71
}
67
72
$ this ->_collection ->load ();
0 commit comments