示例#1
0
文件: Grid.php 项目: aiesh/magento2
 /**
  * @return \Magento\Backend\Block\Widget\Grid
  */
 protected function _prepareCollection()
 {
     $collection = $this->_collectionFactory->create();
     $collection->getEntity()->setStore(0);
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
示例#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();
 }