示例#1
0
文件: Grid.php 项目: aiesh/magento2
 /**
  * @return \Magento\Backend\Block\Widget\Grid
  */
 protected function _prepareCollection()
 {
     $website = $this->getRequest()->getParam('website');
     $group = $this->getRequest()->getParam('group');
     $store = $this->getRequest()->getParam('store');
     if ($website) {
         $storeIds = $this->_storeManager->getWebsite($website)->getStoreIds();
         $storeId = array_pop($storeIds);
     } else {
         if ($group) {
             $storeIds = $this->_storeManager->getGroup($group)->getStoreIds();
             $storeId = array_pop($storeIds);
         } else {
             if ($store) {
                 $storeId = (int) $store;
             } else {
                 $storeId = '';
             }
         }
     }
     /** @var $collection \Magento\Reports\Model\Resource\Product\Lowstock\Collection  */
     $collection = $this->_lowstocksFactory->create()->addAttributeToSelect('*')->setStoreId($storeId)->filterByIsQtyProductTypes()->joinInventoryItem('qty')->useManageStockFilter($storeId)->useNotifyStockQtyFilter($storeId)->setOrder('qty', \Magento\Framework\Data\Collection::SORT_ORDER_ASC);
     if ($storeId) {
         $collection->addStoreFilter($storeId);
     }
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
示例#2
0
 /**
  * Prepare collection for grid
  *
  * @return \Magento\Backend\Block\Widget\Grid
  */
 protected function _prepareCollection()
 {
     if ($this->getRequest()->getParam('queue', false)) {
         $this->getCollection()->useQueue($this->_queueFactory->create()->load($this->getRequest()->getParam('queue')));
     }
     return parent::_prepareCollection();
 }
示例#3
0
文件: Grid.php 项目: DRAJI/Rapidmage
 protected function _prepareCollection()
 {
     if ($this->getCollection()) {
         foreach ($this->getDefaultFilter() as $field => $value) {
             $this->getCollection()->addFieldToFilter($field, $value);
         }
     }
     return parent::_prepareCollection();
 }
示例#4
0
 /**
  * @return Grid
  */
 protected function _prepareCollection()
 {
     if ($this->getCategory()->getId()) {
         $this->setDefaultFilter(['in_category' => 1]);
     }
     $collection = $this->_productFactory->create()->getCollection()->addAttributeToSelect('name')->addAttributeToSelect('image')->addAttributeToSelect('sku')->addAttributeToSelect('price')->addStoreFilter($this->getRequest()->getParam('store'))->joinField('position', 'catalog_category_product', 'position', 'product_id=entity_id', 'category_id=' . (int) $this->getRequest()->getParam('id', 0), 'left');
     $this->setCollection($collection);
     if ($this->getCategory()->getProductsReadonly()) {
         $productIds = $this->_getSelectedProducts();
         if (empty($productIds)) {
             $productIds = 0;
         }
         $this->getCollection()->addFieldToFilter('entity_id', ['in' => $productIds]);
     }
     return \Magento\Backend\Block\Widget\Grid::_prepareCollection();
 }
示例#5
0
 /**
  * Apply sorting and filtering to collection
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     if ($this->getCollection()) {
         if ($this->getCollection()->isLoaded()) {
             $this->getCollection()->clear();
         }
         parent::_prepareCollection();
         if (!$this->_isExport) {
             $this->getCollection()->load();
             $this->_afterLoadCollection();
         }
     }
     return $this;
 }
示例#6
0
 /**
  * Prepare collection for grid
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     $customerId = $this->_coreRegistry->registry('current_customer_id');
     if (!$customerId) {
         $customerId = $this->_coreRegistry->registry('current_customer')->getId();
     }
     $collection = $this->_agreementFactory->create()->addFieldToFilter('customer_id', $customerId)->setOrder('created_at');
     $this->setCollection($collection);
     return \Magento\Backend\Block\Widget\Grid::_prepareCollection();
 }
示例#7
0
 /**
  * Prepare collection for grid
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
     $collection = $this->_agreementFactory->create()->addFieldToFilter('customer_id', $customerId)->setOrder('created_at');
     $this->setCollection($collection);
     return \Magento\Backend\Block\Widget\Grid::_prepareCollection();
 }
示例#8
0
 /**
  * Apply sorting and filtering to collection
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     if ($this->getCollection()) {
         parent::_prepareCollection();
         if (!$this->_isExport) {
             $filter = $this->getParam($this->getVarNameFilter(), null);
             if (is_string($filter)) {
                 $this->getCollection()->removeAllItems();
                 $this->getCollection()->loadWithFilter();
             } else {
                 $this->getCollection()->load();
             }
             $this->_afterLoadCollection();
         }
     }
     return $this;
 }