Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Code.php
Go to the documentation of this file.
1 <?php
7 
15 {
21  protected function _construct()
22  {
23  $this->_init('googleoptimizer_code', 'code_id');
24  }
25 
35  public function loadByEntityType($object, $entityId, $entityType, $storeId)
36  {
37  $connection = $this->getConnection();
38 
39  $select = $connection->select()->from(
40  ['t_def' => $this->getMainTable()],
41  ['entity_id', 'entity_type', 'experiment_script', 'code_id']
42  )->where(
43  't_def.entity_id=?',
44  $entityId
45  )->where(
46  't_def.entity_type=?',
48  )->where(
49  't_def.store_id IN (0, ?)',
50  $storeId
51  )->order(
52  't_def.store_id DESC'
53  )->limit(
54  1
55  );
56 
57  $data = $connection->fetchRow($select);
58 
59  if ($data) {
60  $object->setData($data);
61  }
62  $this->_afterLoad($object);
63  return $this;
64  }
65 }
loadByEntityType($object, $entityId, $entityType, $storeId)
Definition: Code.php:35
$connection
Definition: bulk.php:13
_afterLoad(\Magento\Framework\Model\AbstractModel $object)
Definition: AbstractDb.php:641