55 */
66namespace Magento \Backend \Helper \Dashboard ;
77
8- use Magento \Framework \App \ObjectManager ;
9-
108/**
119 * Adminhtml dashboard helper for orders
1210 *
@@ -18,62 +16,52 @@ class Order extends \Magento\Backend\Helper\Dashboard\AbstractDashboard
1816 /**
1917 * @var \Magento\Reports\Model\ResourceModel\Order\Collection
2018 */
21- protected $ _orderCollection ;
19+ private $ orderCollection ;
2220
2321 /**
2422 * @var \Magento\Store\Model\StoreManagerInterface
2523 * @since 100.0.6
2624 */
27- protected $ _storeManager ;
25+ private $ storeManager ;
2826
2927 /**
3028 * @param \Magento\Framework\App\Helper\Context $context
3129 * @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
3230 */
3331 public function __construct (
3432 \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
3635 ) {
37- $ this ->_orderCollection = $ orderCollection ;
36+ $ this ->orderCollection = $ orderCollection ;
37+ $ this ->storeManager = $ storeManager ;
3838 parent ::__construct ($ context );
3939 }
4040
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-
5641 /**
5742 * @return void
43+ *
44+ * @throws \Magento\Framework\Exception\LocalizedException
45+ * @throws \Magento\Framework\Exception\NoSuchEntityException
5846 */
5947 protected function _initCollection ()
6048 {
6149 $ isFilter = $ this ->getParam ('store ' ) || $ this ->getParam ('website ' ) || $ this ->getParam ('group ' );
6250
63- $ this ->_collection = $ this ->_orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
51+ $ this ->_collection = $ this ->orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
6452
6553 if ($ this ->getParam ('store ' )) {
6654 $ this ->_collection ->addFieldToFilter ('store_id ' , $ this ->getParam ('store ' ));
6755 } elseif ($ this ->getParam ('website ' )) {
68- $ storeIds = $ this ->getStoreManager () ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
56+ $ storeIds = $ this ->storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
6957 $ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
7058 } elseif ($ this ->getParam ('group ' )) {
71- $ storeIds = $ this ->getStoreManager () ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
59+ $ storeIds = $ this ->storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
7260 $ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
7361 } elseif (!$ this ->_collection ->isLive ()) {
7462 $ this ->_collection ->addFieldToFilter (
7563 '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 ()]
7765 );
7866 }
7967 $ this ->_collection ->load ();
0 commit comments