Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Order.php
Go to the documentation of this file.
1 <?php
7 
9 
16 class Order extends AbstractDashboard
17 {
21  protected $_orderCollection;
22 
27  protected $_storeManager;
28 
34  public function __construct(
35  \Magento\Framework\App\Helper\Context $context,
36  \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection,
37  \Magento\Store\Model\StoreManagerInterface $storeManager = null
38  ) {
39  $this->_orderCollection = $orderCollection;
40  $this->_storeManager = $storeManager ?: ObjectManager::getInstance()
41  ->get(\Magento\Store\Model\StoreManagerInterface::class);
42 
43  parent::__construct($context);
44  }
45 
52  protected function _initCollection()
53  {
54  $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
55 
56  $this->_collection = $this->_orderCollection->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
57 
58  if ($this->getParam('store')) {
59  $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
60  } elseif ($this->getParam('website')) {
61  $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
62  $this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
63  } elseif ($this->getParam('group')) {
64  $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
65  $this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
66  } elseif (!$this->_collection->isLive()) {
67  $this->_collection->addFieldToFilter(
68  'store_id',
69  ['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]
70  );
71  }
72  $this->_collection->load();
73  }
74 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$storeManager
$this _collection
Definition: coupons.php:7
__construct(\Magento\Framework\App\Helper\Context $context, \Magento\Reports\Model\ResourceModel\Order\Collection $orderCollection, \Magento\Store\Model\StoreManagerInterface $storeManager=null)
Definition: Order.php:34