/** * filter by store * * @param Collection $collection * @param Column $column * @return $this */ public function filterStoreCondition(Collection $collection, Column $column) { if (!($value = $column->getFilter()->getValue())) { return $this; } $collection->addStoreFilter($value); return $this; }
/** * @return \Sample\News\Model\ResourceModel\Author\Collection */ public function getAuthorCollection() { if (is_null($this->authorCollection)) { $this->authorCollection = $this->categoryModel->getSelectedAuthorsCollection($this->getCategory())->addStoreFilter($this->_storeManager->getStore()->getId())->addFieldToFilter('is_active', 1); //TODO: use constant here $this->authorCollection->getSelect()->order('related_category.position'); } return $this->authorCollection; }
/** * constructor * * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy * @param \Magento\Framework\Event\ManagerInterface $eventManager * @param $mainTable * @param $eventPrefix * @param $eventObject * @param $resourceModel * @param $model * @param $connection * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource */ public function __construct(EntityFactoryInterface $entityFactory, LoggerInterface $logger, FetchStrategyInterface $fetchStrategy, ManagerInterface $eventManager, StoreManagerInterface $storeManager, $mainTable, $eventPrefix, $eventObject, $resourceModel, $model = 'Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document', $connection = null, AbstractDb $resource = null) { parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $storeManager, $connection, $resource); $this->_eventPrefix = $eventPrefix; $this->_eventObject = $eventObject; $this->_init($model, $resourceModel); $this->setMainTable($mainTable); }