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
13 
19 {
27  protected function _joinFields($fromDate = '', $toDate = '')
28  {
29  $this->getSelect()->reset(\Magento\Framework\DB\Select::COLUMNS);
30  $this->addAttributeToFilter(
31  'created_at',
32  ['from' => $fromDate, 'to' => $toDate, 'datetime' => true]
33  )->addExpressionAttributeToSelect(
34  'accounts',
35  'COUNT({{entity_id}})',
36  ['entity_id']
37  );
38 
39  $this->getSelect()->having("{$this->_joinFields['accounts']['field']} > ?", 0);
40 
41  return $this;
42  }
43 
51  public function setDateRange($fromDate, $toDate)
52  {
53  $this->_reset()->_joinFields($fromDate, $toDate);
54  return $this;
55  }
56 
63  public function setStoreIds($storeIds)
64  {
65  if ($storeIds) {
66  $this->addAttributeToFilter('store_id', ['in' => (array)$storeIds]);
67  }
68  return $this;
69  }
70 }
addAttributeToFilter($attribute, $condition=null, $joinType='inner')