55 */
66namespace Magento \Backend \Helper \Dashboard ;
77
8+ use Magento \Framework \App \ObjectManager ;
9+
810/**
911 * Adminhtml dashboard helper for orders
1012 *
1113 * @api
1214 * @since 100.0.2
1315 */
14- class Order extends \ Magento \ Backend \ Helper \ Dashboard \ AbstractDashboard
16+ class Order extends AbstractDashboard
1517{
1618 /**
1719 * @var \Magento\Reports\Model\ResourceModel\Order\Collection
1820 */
19- private $ orderCollection ;
21+ private $ _orderCollection ;
2022
2123 /**
2224 * @var \Magento\Store\Model\StoreManagerInterface
2325 * @since 100.0.6
2426 */
25- private $ storeManager ;
27+ private $ _storeManager ;
2628
2729 /**
2830 * @param \Magento\Framework\App\Helper\Context $context
2931 * @param \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection
32+ * @param \Magento\Store\Model\StoreManagerInterface $storeManager
3033 */
3134 public function __construct (
3235 \Magento \Framework \App \Helper \Context $ context ,
3336 \Magento \Reports \Model \ResourceModel \Order \Collection $ orderCollection ,
34- \Magento \Store \Model \StoreManagerInterface $ storeManager
37+ \Magento \Store \Model \StoreManagerInterface $ storeManager = null
3538 ) {
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+
3843 parent ::__construct ($ context );
3944 }
4045
@@ -48,20 +53,20 @@ protected function _initCollection()
4853 {
4954 $ isFilter = $ this ->getParam ('store ' ) || $ this ->getParam ('website ' ) || $ this ->getParam ('group ' );
5055
51- $ this ->_collection = $ this ->orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
56+ $ this ->_collection = $ this ->_orderCollection ->prepareSummary ($ this ->getParam ('period ' ), 0 , 0 , $ isFilter );
5257
5358 if ($ this ->getParam ('store ' )) {
5459 $ this ->_collection ->addFieldToFilter ('store_id ' , $ this ->getParam ('store ' ));
5560 } elseif ($ this ->getParam ('website ' )) {
56- $ storeIds = $ this ->storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
61+ $ storeIds = $ this ->_storeManager ->getWebsite ($ this ->getParam ('website ' ))->getStoreIds ();
5762 $ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
5863 } elseif ($ this ->getParam ('group ' )) {
59- $ storeIds = $ this ->storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
64+ $ storeIds = $ this ->_storeManager ->getGroup ($ this ->getParam ('group ' ))->getStoreIds ();
6065 $ this ->_collection ->addFieldToFilter ('store_id ' , ['in ' => implode (', ' , $ storeIds )]);
6166 } elseif (!$ this ->_collection ->isLive ()) {
6267 $ this ->_collection ->addFieldToFilter (
6368 '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 ()]
6570 );
6671 }
6772 $ this ->_collection ->load ();
0 commit comments