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 
14 {
20  protected $_storeId = 0;
21 
27  protected function _construct()
28  {
29  parent::_construct();
30  $this->_init(\Magento\Variable\Model\Variable::class, \Magento\Variable\Model\ResourceModel\Variable::class);
31  }
32 
39  public function setStoreId($storeId)
40  {
41  $this->_storeId = $storeId;
42  return $this;
43  }
44 
50  public function getStoreId()
51  {
52  return $this->_storeId;
53  }
54 
60  public function addValuesToResult()
61  {
62  $this->getSelect()->join(
63  ['value_table' => $this->getTable('variable_value')],
64  'value_table.variable_id = main_table.variable_id',
65  ['value_table.plain_value', 'value_table.html_value']
66  );
67  $this->addFieldToFilter('value_table.store_id', ['eq' => $this->getStoreId()]);
68  return $this;
69  }
70 
76  public function toOptionArray()
77  {
78  return $this->_toOptionArray('code', 'name');
79  }
80 }
_toOptionArray($valueField=null, $labelField='name', $additional=[])
Definition: AbstractDb.php:641