Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Collection.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $dateTime;
17 
27  public function __construct(
28  \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
29  \Psr\Log\LoggerInterface $logger,
30  \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
31  \Magento\Framework\Event\ManagerInterface $eventManager,
32  \Magento\Framework\Stdlib\DateTime $dateTime,
33  \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
34  \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
35  ) {
36  $this->dateTime = $dateTime;
37  parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
38  }
39 
45  protected function _construct()
46  {
47  $this->_init(\Magento\Theme\Model\Design::class, \Magento\Theme\Model\ResourceModel\Design::class);
48  }
49 
55  public function joinStore()
56  {
57  return $this->join(['cs' => 'store'], 'cs.store_id = main_table.store_id', ['cs.name']);
58  }
59 
66  public function addDateFilter($date = null)
67  {
68  if ($date === null) {
69  $date = $this->dateTime->formatDate(true);
70  } else {
71  $date = $this->dateTime->formatDate($date);
72  }
73 
74  $this->addFieldToFilter('date_from', ['lteq' => $date]);
75  $this->addFieldToFilter('date_to', ['gteq' => $date]);
76  return $this;
77  }
78 
85  public function addStoreFilter($storeId)
86  {
87  return $this->addFieldToFilter('store_id', ['in' => $storeId]);
88  }
89 }
__construct(\Magento\Framework\Data\Collection\EntityFactory $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Framework\Stdlib\DateTime $dateTime, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource=null)
Definition: Collection.php:27
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13