|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Customer\Address\Repositories\CustomerAddressVarcharRepository |
|
5
|
|
|
* |
|
6
|
|
|
* PHP version 7 |
|
7
|
|
|
* |
|
8
|
|
|
* @author Tim Wagner <[email protected]> |
|
9
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
|
10
|
|
|
* @license https://opensource.org/licenses/MIT |
|
11
|
|
|
* @link https://github.com/techdivision/import-customer-address |
|
12
|
|
|
* @link http://www.techdivision.com |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace TechDivision\Import\Customer\Address\Repositories; |
|
16
|
|
|
|
|
17
|
|
|
use TechDivision\Import\Customer\Address\Utils\ParamNames; |
|
18
|
|
|
use TechDivision\Import\Customer\Address\Utils\SqlStatementKeys; |
|
19
|
|
|
use TechDivision\Import\Dbal\Collection\Repositories\AbstractRepository; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Repository implementation to load customer varchar attribute data. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Tim Wagner <[email protected]> |
|
25
|
|
|
* @copyright 2018 TechDivision GmbH <[email protected]> |
|
26
|
|
|
* @license https://opensource.org/licenses/MIT |
|
27
|
|
|
* @link https://github.com/techdivision/import-customer-address |
|
28
|
|
|
* @link http://www.techdivision.com |
|
29
|
|
|
*/ |
|
30
|
|
|
class CustomerAddressVarcharRepository extends AbstractRepository implements CustomerAddressVarcharRepositoryInterface |
|
31
|
|
|
{ |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The prepared statement to load the existing customer varchar attributes with the passed entity/store ID. |
|
35
|
|
|
* |
|
36
|
|
|
* @var \PDOStatement |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $customerVarcharsStmt; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The prepared statement to load the existing customer varchar attribute with the passed attribute code |
|
42
|
|
|
* entity type/store ID as well as the passed value. |
|
43
|
|
|
* |
|
44
|
|
|
* @var \PDOStatement |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $customerVarcharByAttributeCodeAndEntityTypeIdAndAndValueStmt; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Initializes the repository's prepared statements. |
|
50
|
|
|
* |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
public function init() |
|
54
|
|
|
{ |
|
55
|
|
|
|
|
56
|
|
|
// initialize the prepared statements |
|
57
|
|
|
$this->customerVarcharsStmt = |
|
58
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESS_VARCHARS)); |
|
59
|
|
|
$this->customerVarcharByAttributeCodeAndEntityTypeIdAndAndValueStmt = |
|
60
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_ADDRESS_VARCHAR_BY_ATTRIBUTE_CODE_AND_ENTITY_TYPE_ID_AND_VALUE)); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Load's and return's the varchar attributes for the passed entity ID. |
|
65
|
|
|
* |
|
66
|
|
|
* @param integer $entityId The entity ID of the attributes |
|
67
|
|
|
* |
|
68
|
|
|
* @return array The varchar attributes |
|
69
|
|
|
*/ |
|
70
|
|
|
public function findAllByEntityId($entityId) |
|
71
|
|
|
{ |
|
72
|
|
|
|
|
73
|
|
|
// prepare the params |
|
74
|
|
|
$params = array(ParamNames::ENTITY_ID => $entityId); |
|
75
|
|
|
|
|
76
|
|
|
// load and return the customer varchar attributes with the passed entity ID |
|
77
|
|
|
$this->customerVarcharsStmt->execute($params); |
|
78
|
|
|
return $this->customerVarcharsStmt->fetchAll(\PDO::FETCH_ASSOC); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Load's and return's the varchar attribute with the passed params. |
|
83
|
|
|
* |
|
84
|
|
|
* @param integer $attributeCode The attribute code of the varchar attribute |
|
85
|
|
|
* @param integer $entityTypeId The entity type ID of the varchar attribute |
|
86
|
|
|
* @param string $value The value of the varchar attribute |
|
87
|
|
|
* |
|
88
|
|
|
* @return array|null The varchar attribute |
|
89
|
|
|
*/ |
|
90
|
|
|
public function findOneByAttributeCodeAndEntityTypeIdAndAndValue($attributeCode, $entityTypeId, $value) |
|
91
|
|
|
{ |
|
92
|
|
|
|
|
93
|
|
|
// prepare the params |
|
94
|
|
|
$params = array( |
|
95
|
|
|
ParamNames::ATTRIBUTE_CODE => $attributeCode, |
|
96
|
|
|
ParamNames::ENTITY_TYPE_ID => $entityTypeId, |
|
97
|
|
|
ParamNames::VALUE => $value |
|
98
|
|
|
); |
|
99
|
|
|
|
|
100
|
|
|
// load and return the customer varchar attribute with the passed parameters |
|
101
|
|
|
$this->customerVarcharByAttributeCodeAndEntityTypeIdAndAndValueStmt->execute($params); |
|
102
|
|
|
return $this->customerVarcharByAttributeCodeAndEntityTypeIdAndAndValueStmt->fetch(\PDO::FETCH_ASSOC); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|