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 $_map = [
17  'fields' => [
18  'agreement_id' => 'main_table.agreement_id'
19  ]
20  ];
21 
27  protected $_isStoreFilterWithAdmin = true;
28 
34  protected function _construct()
35  {
36  $this->_init(
37  \Magento\CheckoutAgreements\Model\Agreement::class,
38  \Magento\CheckoutAgreements\Model\ResourceModel\Agreement::class
39  );
40  }
41 
48  public function addStoreFilter($store)
49  {
50  // check and prepare data
51  if ($store instanceof \Magento\Store\Model\Store) {
52  $store = [$store->getId()];
53  } elseif (is_numeric($store)) {
54  $store = [$store];
55  }
56 
57  $alias = 'store_table_' . implode('_', $store);
58  if ($this->getFlag($alias)) {
59  return $this;
60  }
61 
62  $storeFilter = [$store];
63  if ($this->_isStoreFilterWithAdmin) {
64  $storeFilter[] = 0;
65  }
66 
67  // add filter
68  $this->getSelect()->join(
69  [$alias => $this->getTable('checkout_agreement_store')],
70  'main_table.agreement_id = ' . $alias . '.agreement_id',
71  []
72  )->where(
73  $alias . '.store_id IN (?)',
74  $storeFilter
75  )->group(
76  'main_table.agreement_id'
77  );
78 
79  $this->setFlag($alias, true);
80  return $this;
81  }
82 
91  {
92  $this->_isStoreFilterWithAdmin = (bool)$value;
93  return $this;
94  }
95 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$value
Definition: gender.phtml:16
if(!trim($html)) $alias
Definition: details.phtml:20