|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Attribute\Set\Repositories\EntityAttributeRepository |
|
5
|
|
|
* |
|
6
|
|
|
* PHP version 7 |
|
7
|
|
|
* |
|
8
|
|
|
* @author Tim Wagner <[email protected]> |
|
9
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
10
|
|
|
* @license https://opensource.org/licenses/MIT |
|
11
|
|
|
* @link https://github.com/techdivision/import-attribute-set |
|
12
|
|
|
* @link http://www.techdivision.com |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace TechDivision\Import\Attribute\Set\Repositories; |
|
16
|
|
|
|
|
17
|
|
|
use TechDivision\Import\Attribute\Set\Utils\SqlStatementKeys; |
|
18
|
|
|
use TechDivision\Import\Attribute\Set\Utils\MemberNames; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Repository implementation to load EAV entity attribute data. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Tim Wagner <[email protected]> |
|
24
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
25
|
|
|
* @license https://opensource.org/licenses/MIT |
|
26
|
|
|
* @link https://github.com/techdivision/import-attribute-set |
|
27
|
|
|
* @link http://www.techdivision.com |
|
28
|
|
|
*/ |
|
29
|
|
|
class EntityAttributeRepository extends \TechDivision\Import\Attribute\Repositories\EntityAttributeRepository implements EntityAttributeRepositoryInterface |
|
30
|
|
|
{ |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* The prepared statement to load an existing EAV entity attributes for the given attribute group ID. |
|
34
|
|
|
* |
|
35
|
|
|
* @var \PDOStatement |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $entityAttributeByAttributeGroupId; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* The prepared statement to load an existing EAV entity attributes for the given entity type ID and attribute set name. |
|
41
|
|
|
* |
|
42
|
|
|
* @var \PDOStatement |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $entityAttributeByEntityTypeIdAndAttributeSetNameStmt; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Initializes the repository's prepared statements. |
|
48
|
|
|
* |
|
49
|
|
|
* @return void |
|
50
|
|
|
*/ |
|
51
|
|
|
public function init() |
|
52
|
|
|
{ |
|
53
|
|
|
|
|
54
|
|
|
// invoke the parent instance |
|
55
|
|
|
parent::init(); |
|
56
|
|
|
|
|
57
|
|
|
// initialize the prepared statements |
|
58
|
|
|
$this->entityAttributeByAttributeGroupId = |
|
59
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::ENTITY_ATTRIBUTES_BY_ATTRIBUTE_GROUP_ID)); |
|
60
|
|
|
$this->entityAttributeByEntityTypeIdAndAttributeSetNameStmt = |
|
61
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::ENTITY_ATTRIBUTES_BY_ENTITY_TYPE_ID_AND_ATTRIBUTE_SET_NAME)); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Returns the EAV entity attributes for the attribute group with the passed ID. |
|
66
|
|
|
* |
|
67
|
|
|
* @param integer $attributeGroupId The attribute group ID to load the EAV entity attributes for |
|
68
|
|
|
* |
|
69
|
|
|
* @return array|null The EAV attributes with for the passed attribute group ID |
|
70
|
|
|
*/ |
|
71
|
|
|
public function findAllByAttributeGroupId($attributeGroupId) |
|
72
|
|
|
{ |
|
73
|
|
|
|
|
74
|
|
|
// load and return the EAV attribute options with the passed parameters |
|
75
|
|
|
$this->entityAttributeByAttributeGroupId->execute(array(MemberNames::ATTRIBUTE_GROUP_ID => $attributeGroupId)); |
|
76
|
|
|
return $this->entityAttributeByAttributeGroupId->fetchAll(\PDO::FETCH_ASSOC); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Returns the EAV entity attributes for the entity type ID and attribute set with the passed name. |
|
81
|
|
|
* |
|
82
|
|
|
* @param integer $entityTypeId The entity type ID to load the EAV entity attributes for |
|
83
|
|
|
* @param string $attributeSetName The attribute set name to return the EAV entity attributes for |
|
84
|
|
|
* |
|
85
|
|
|
* @return array|null The EAV attributes with for the passed entity type ID and attribute set name |
|
86
|
|
|
*/ |
|
87
|
|
|
public function findAllByEntityTypeIdAndAttributeSetName($entityTypeId, $attributeSetName) |
|
88
|
|
|
{ |
|
89
|
|
|
|
|
90
|
|
|
// initialize the params |
|
91
|
|
|
$params = array( |
|
92
|
|
|
MemberNames::ENTITY_TYPE_ID => $entityTypeId, |
|
93
|
|
|
MemberNames::ATTRIBUTE_SET_NAME => $attributeSetName |
|
94
|
|
|
); |
|
95
|
|
|
|
|
96
|
|
|
// load and return the EAV attribute options with the passed parameters |
|
97
|
|
|
$this->entityAttributeByEntityTypeIdAndAttributeSetNameStmt->execute($params); |
|
98
|
|
|
return $this->entityAttributeByEntityTypeIdAndAttributeSetNameStmt->fetchAll(\PDO::FETCH_ASSOC); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|