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