-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Expand file tree
/
Copy pathStore.php
More file actions
60 lines (53 loc) · 1.38 KB
/
Store.php
File metadata and controls
60 lines (53 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Copyright 2015 Adobe
* All Rights Reserved.
*/
namespace Magento\Eav\Model\ResourceModel\Entity;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\DataObject;
/**
* Eav Entity store resource model
*/
class Store extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/**
* Resource initialization
*
* @return void
* @codeCoverageIgnore
*/
protected function _construct()
{
$this->_init('eav_entity_store', 'entity_store_id');
}
/**
* Load an object by entity type and store
*
* @param Object|\Magento\Framework\Model\AbstractModel $object
* @param int $entityTypeId
* @param int $storeId
* @return bool
*/
public function loadByEntityStore(AbstractModel $object, $entityTypeId, $storeId)
{
$connection = $this->getConnection();
$bind = [':entity_type_id' => $entityTypeId, ':store_id' => $storeId];
$select = $connection->select()->from(
$this->getMainTable()
)->forUpdate(
true
)->where(
'entity_type_id = :entity_type_id'
)->where(
'store_id = :store_id'
);
$data = $connection->fetchRow($select, $bind);
if (!$data) {
return false;
}
$object->setData($data);
$this->_afterLoad($object);
return true;
}
}