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
*/
@@ -15,6 +17,11 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
15
17
*/
16
18
protected $ _orderCollection ;
17
19
20
+ /**
21
+ * @var \Magento\Store\Model\StoreManagerInterface
22
+ */
23
+ protected $ _storeManager ;
24
+
18
25
/**
19
26
* @param \Magento\Framework\App\Helper\Context $context
20
27
* @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
@@ -41,17 +48,31 @@ protected function _initCollection()
41
48
if ($ this ->getParam ('store ' )) {
42
49
$ this ->_collection ->addFieldToFilter ('store_id ' , $ this ->getParam ('store ' ));
43
50
} elseif ($ this ->getParam ('website ' )) {
44
- $ storeIds = $ this ->_storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
51
+ $ storeIds = $ this ->getStoreManager () ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
45
52
$ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
46
53
} elseif ($ this ->getParam ('group ' )) {
47
- $ storeIds = $ this ->_storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
54
+ $ storeIds = $ this ->getStoreManager () ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
48
55
$ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
49
56
} elseif (!$ this ->_collection ->isLive ()) {
50
57
$ this ->_collection ->addFieldToFilter (
51
58
'store_id ' ,
52
- ['eq ' => $ this ->_storeManager ->getStore (\Magento \Store \Model \Store::ADMIN_CODE )->getId ()]
59
+ ['eq ' => $ this ->getStoreManager () ->getStore (\Magento \Store \Model \Store::ADMIN_CODE )->getId ()]
53
60
);
54
61
}
55
62
$ this ->_collection ->load ();
56
63
}
64
+
65
+ /**
66
+ * Get Store Manager
67
+ *
68
+ * @return \Magento\Store\Model\StoreManagerInterface
69
+ */
70
+ public function getStoreManager ()
71
+ {
72
+ if (!$ this ->_storeManager ) {
73
+ $ this ->_storeManager = ObjectManager::getInstance ()->get ('Magento\Store\Model\StoreManager ' );
74
+ }
75
+
76
+ return $ this ->_storeManager ;
77
+ }
57
78
}
0 commit comments