Example #1
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     if ($this->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
         $storeId = array_pop($storeIds);
     } elseif ($this->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
         $storeId = array_pop($storeIds);
     } else {
         $storeId = (int) $this->getParam('store');
     }
     $collection = $this->_productsFactory->create()->addAttributeToSelect('*')->addViewsCount()->setStoreId($storeId)->addStoreFilter($storeId);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     $this->_collection = $this->_queriesFactory->create();
     if ($this->getRequest()->getParam('store')) {
         $storeIds = $this->getRequest()->getParam('store');
     } elseif ($this->getRequest()->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
     } elseif ($this->getRequest()->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
     } else {
         $storeIds = '';
     }
     $this->_collection->setPopularQueryFilter($storeIds);
     $this->setCollection($this->_collection);
     return parent::_prepareCollection();
 }
Example #3
0
 /**
  * @return $this
  */
 protected function _prepareCollection()
 {
     $this->_collection = $this->_queriesFactory->create();
     $this->_collection->setRecentQueryFilter();
     if ($this->getRequest()->getParam('store')) {
         $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
     } elseif ($this->getRequest()->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
         $this->_collection->addFieldToFilter('store_id', ['in' => $storeIds]);
     } elseif ($this->getRequest()->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
         $this->_collection->addFieldToFilter('store_id', ['in' => $storeIds]);
     }
     $this->setCollection($this->_collection);
     return parent::_prepareCollection();
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create()->addCustomerName();
     $storeFilter = 0;
     if ($this->getParam('store')) {
         $collection->addAttributeToFilter('store_id', $this->getParam('store'));
         $storeFilter = 1;
     } elseif ($this->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
         $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
     } elseif ($this->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
         $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
     }
     $collection->addOrdersStatistics($storeFilter)->orderByCustomerRegistration();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     if (!$this->_moduleManager->isEnabled('Magento_Sales')) {
         return $this;
     }
     if ($this->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
         $storeId = array_pop($storeIds);
     } elseif ($this->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
         $storeId = array_pop($storeIds);
     } else {
         $storeId = (int) $this->getParam('store');
     }
     $collection = $this->_collectionFactory->create()->setModel('Magento\\Catalog\\Model\\Product')->addStoreFilter($storeId);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create();
     /* @var $collection \Magento\Reports\Model\ResourceModel\Order\Collection */
     $collection->groupByCustomer()->addOrdersCount()->joinCustomerName();
     $storeFilter = 0;
     if ($this->getParam('store')) {
         $collection->addAttributeToFilter('store_id', $this->getParam('store'));
         $storeFilter = 1;
     } elseif ($this->getParam('website')) {
         $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
         $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
     } elseif ($this->getParam('group')) {
         $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
         $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
     }
     $collection->addSumAvgTotals($storeFilter)->orderByTotalAmount();
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #7
0
 /**
  * @return $this
  */
 protected function _prepareCollection()
 {
     if (!$this->_moduleManager->isEnabled('Magento_Reports')) {
         return $this;
     }
     $collection = $this->_collectionFactory->create()->addItemCountExpr()->joinCustomerName('customer')->orderByCreatedAt();
     if ($this->getParam('store') || $this->getParam('website') || $this->getParam('group')) {
         if ($this->getParam('store')) {
             $collection->addAttributeToFilter('store_id', $this->getParam('store'));
         } elseif ($this->getParam('website')) {
             $storeIds = $this->_storeManager->getWebsite($this->getParam('website'))->getStoreIds();
             $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
         } elseif ($this->getParam('group')) {
             $storeIds = $this->_storeManager->getGroup($this->getParam('group'))->getStoreIds();
             $collection->addAttributeToFilter('store_id', ['in' => $storeIds]);
         }
         $collection->addRevenueToSelect();
     } else {
         $collection->addRevenueToSelect(true);
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #8
0
 /**
  * @return $this
  */
 protected function _prepareCollection()
 {
     if (!$this->_moduleManager->isEnabled('Magento_CatalogSearch')) {
         return parent::_prepareCollection();
     }
     $this->_collection = $this->_queriesFactory->create();
     $this->_collection->setRecentQueryFilter();
     if ($this->getRequest()->getParam('store')) {
         $this->_collection->addFieldToFilter('store_id', $this->getRequest()->getParam('store'));
     } else {
         if ($this->getRequest()->getParam('website')) {
             $storeIds = $this->_storeManager->getWebsite($this->getRequest()->getParam('website'))->getStoreIds();
             $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
         } else {
             if ($this->getRequest()->getParam('group')) {
                 $storeIds = $this->_storeManager->getGroup($this->getRequest()->getParam('group'))->getStoreIds();
                 $this->_collection->addFieldToFilter('store_id', array('in' => $storeIds));
             }
         }
     }
     $this->setCollection($this->_collection);
     return parent::_prepareCollection();
 }