Example #1
0
 /**
  * @return \Magento\Backend\Block\Widget\Grid
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create();
     $collection->getEntity()->setStore(0);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #2
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();
 }