Exemple #1
0
 /**
  * @return void
  */
 protected function _initCollection()
 {
     $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
     $this->_collection = $this->_orderCollection->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
     if ($this->getParam('store')) {
         $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
     } elseif ($this->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
         $this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
     } elseif ($this->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
         $this->_collection->addFieldToFilter('store_id', ['in' => implode(',', $storeIds)]);
     } elseif (!$this->_collection->isLive()) {
         $this->_collection->addFieldToFilter('store_id', ['eq' => $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId()]);
     }
     $this->_collection->load();
 }
Exemple #2
0
 /**
  * Set order
  *
  * @param string $attribute
  * @param string $dir
  * @return $this
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
 {
     if (in_array($attribute, ['orders', 'ordered_qty'])) {
         $this->getSelect()->order($attribute . ' ' . $dir);
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
Exemple #3
0
 /**
  * @param array $storeIds
  * @param array $parameters
  * @dataProvider storesDataProvider
  * @return void
  */
 public function testSetStoreIds($storeIds, $parameters)
 {
     $this->dbMock->expects($this->any())->method('getIfNullSql')->willReturn('text');
     $this->selectMock->expects($this->once())->method('columns')->with($parameters)->willReturnSelf();
     $this->collection->setStoreIds($storeIds);
 }