1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\TierPrice\Repositories\CustomerGroupRepository |
5
|
|
|
* |
6
|
|
|
* PHP version 7 |
7
|
|
|
* |
8
|
|
|
* @author Klaas-Tido Rühl <[email protected]> |
9
|
|
|
* @author Tim Wagner <[email protected]> |
10
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
11
|
|
|
* @license https://opensource.org/licenses/MIT |
12
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
13
|
|
|
* @link https://www.techdivision.com |
14
|
|
|
* @link https://www.refusion.com |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace TechDivision\Import\Product\TierPrice\Repositories; |
18
|
|
|
|
19
|
|
|
use TechDivision\Import\Dbal\Collection\Repositories\AbstractRepository; |
20
|
|
|
use TechDivision\Import\Product\TierPrice\Utils\MemberNames; |
21
|
|
|
use TechDivision\Import\Product\TierPrice\Utils\SqlStatementKeys; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The default repository implementation for loading customer groups. |
25
|
|
|
* |
26
|
|
|
* @author Klaas-Tido Rühl <[email protected]> |
27
|
|
|
* @author Tim Wagner <[email protected]> |
28
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
29
|
|
|
* @license https://opensource.org/licenses/MIT |
30
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
31
|
|
|
* @link https://www.techdivision.com |
32
|
|
|
* @link https://www.refusion.com |
33
|
|
|
*/ |
34
|
|
|
class CustomerGroupRepository extends AbstractRepository implements CustomerGroupRepositoryInterface |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The prepared statement to load the customer groups. |
39
|
|
|
* |
40
|
|
|
* @var \PDOStatement |
41
|
|
|
*/ |
42
|
|
|
protected $customerGroupsStmt; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Initializes the repository's prepared statements. |
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
public function init() |
50
|
|
|
{ |
51
|
|
|
// initialize the prepared statements |
52
|
|
|
$this->customerGroupsStmt = |
53
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::CUSTOMER_GROUPS)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Returns an array with the available customer groups and their code as keys. |
58
|
|
|
* |
59
|
|
|
* @return array The array with the customer groups |
60
|
|
|
*/ |
61
|
|
|
public function findAll() |
62
|
|
|
{ |
63
|
|
|
|
64
|
|
|
// initialize the array for the customer groups |
65
|
|
|
$customerGroups = []; |
66
|
|
|
|
67
|
|
|
// execute the prepared statement |
68
|
|
|
$this->customerGroupsStmt->execute(); |
69
|
|
|
|
70
|
|
|
// fetch the customer groups and assemble them as array with the codes as key |
71
|
|
|
foreach ($this->customerGroupsStmt->fetchAll() as $customerGroup) { |
72
|
|
|
$customerGroups[$customerGroup[MemberNames::CUSTOMER_GROUP_CODE]] = $customerGroup; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// return the customer groups |
76
|
|
|
return $customerGroups; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|