1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\TierPrice\Repositories\TierPriceRepository |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Klaas-Tido Rühl <[email protected]> |
15
|
|
|
* @author Tim Wagner <[email protected]> |
16
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
17
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
18
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
19
|
|
|
* @link https://www.techdivision.com |
20
|
|
|
* @link https://www.refusion.com |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace TechDivision\Import\Product\TierPrice\Repositories; |
24
|
|
|
|
25
|
|
|
use TechDivision\Import\Utils\PrimaryKeyUtilInterface; |
|
|
|
|
26
|
|
|
use TechDivision\Import\Connection\ConnectionInterface; |
27
|
|
|
use TechDivision\Import\Repositories\AbstractRepository; |
28
|
|
|
use TechDivision\Import\Product\TierPrice\Utils\MemberNames; |
29
|
|
|
use TechDivision\Import\Product\TierPrice\Utils\SqlStatementKeys; |
30
|
|
|
use TechDivision\Import\Repositories\SqlStatementRepositoryInterface; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Default implementation of repository for accessing tier price data. |
34
|
|
|
* |
35
|
|
|
* @author Klaas-Tido Rühl <[email protected]> |
36
|
|
|
* @author Tim Wagner <[email protected]> |
37
|
|
|
* @copyright 2019 REFUSiON GmbH <[email protected]> |
38
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
39
|
|
|
* @link https://github.com/techdivision/import-product-tier-price |
40
|
|
|
* @link https://www.techdivision.com |
41
|
|
|
* @link https://www.refusion.com |
42
|
|
|
*/ |
43
|
|
|
class TierPriceRepository extends AbstractRepository implements TierPriceRepositoryInterface |
44
|
|
|
{ |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* The primary key util instance. |
48
|
|
|
* |
49
|
|
|
* @var \TechDivision\Import\Utils\PrimaryKeyUtilInterface |
50
|
|
|
*/ |
51
|
|
|
protected $primaryKeyUtil; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* The prepared statement to load the existing tier prices. |
55
|
|
|
* |
56
|
|
|
* @var \PDOStatement |
57
|
|
|
*/ |
58
|
|
|
protected $tierPricesStmt; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* The prepared statement to load an existing tier price by PK, all groups, customer group ID, qty and website ID. |
62
|
|
|
* |
63
|
|
|
* @var \PDOStatement |
64
|
|
|
*/ |
65
|
|
|
protected $tierPriceByPkAndAllGroupsAndCustomerGroupIdAndQtyAndWebsiteIdStmt; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Initialize the repository with the passed connection and utility class name. |
69
|
|
|
* . |
70
|
|
|
* @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance |
71
|
|
|
* @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The SQL repository instance |
72
|
|
|
* @param \TechDivision\Import\Utils\PrimaryKeyUtilInterface $primaryKeyUtil The primary key util instance |
73
|
|
|
*/ |
74
|
|
|
public function __construct( |
75
|
|
|
ConnectionInterface $connection, |
76
|
|
|
SqlStatementRepositoryInterface $sqlStatementRepository, |
77
|
|
|
PrimaryKeyUtilInterface $primaryKeyUtil |
78
|
|
|
) { |
79
|
|
|
|
80
|
|
|
// pass the connection and the SQL statement repository through to the parent instance |
81
|
|
|
parent::__construct($connection, $sqlStatementRepository); |
82
|
|
|
|
83
|
|
|
// set the primary key util |
84
|
|
|
$this->primaryKeyUtil = $primaryKeyUtil; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Returns the primary key util instance. |
89
|
|
|
* |
90
|
|
|
* @return \TechDivision\Import\Utils\PrimaryKeyUtilInterface The primary key util instance |
91
|
|
|
*/ |
92
|
|
|
public function getPrimaryKeyUtil() |
93
|
|
|
{ |
94
|
|
|
return $this->primaryKeyUtil; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Returns the primary key member name for the actual Magento edition. |
99
|
|
|
* |
100
|
|
|
* @return string The primary key member name |
101
|
|
|
* @see \TechDivision\Import\Utils\PrimaryKeyUtilInterface::getPrimaryKeyMemberName() |
102
|
|
|
*/ |
103
|
|
|
public function getPrimaryKeyMemberName() |
104
|
|
|
{ |
105
|
|
|
return $this->getPrimaryKeyUtil()->getPrimaryKeyMemberName(); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Initializes the repository's prepared statements. |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function init() |
114
|
|
|
{ |
115
|
|
|
// initialize the prepared statements |
116
|
|
|
$this->tierPricesStmt = |
117
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::TIER_PRICES)); |
118
|
|
|
$this->tierPriceByPkAndAllGroupsAndCustomerGroupIdAndQtyAndWebsiteIdStmt = |
119
|
|
|
$this->getConnection()->prepare($this->loadStatement(SqlStatementKeys::TIER_PRICE_BY_PK_AND_ALL_GROUPS_AND_CUSTOMER_GROUP_ID_AND_QTY_AND_WEBSITE_ID)); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* Returns the tier price with the given parameters. |
124
|
|
|
* |
125
|
|
|
* @param string $pk The PK of the product relation |
126
|
|
|
* @param integer $allGroups The flag if all groups are affected or not |
127
|
|
|
* @param integer $customerGroupId The customer group ID |
128
|
|
|
* @param integer $qty The tier price quantity |
129
|
|
|
* @param integer $websiteId The website ID the tier price is related to |
130
|
|
|
* |
131
|
|
|
* @return array The tier price |
132
|
|
|
*/ |
133
|
|
|
public function findOneByPkAndAllGroupsAndCustomerGroupIdAndQtyAndWebsiteId($pk, $allGroups, $customerGroupId, $qty, $websiteId) |
134
|
|
|
{ |
135
|
|
|
|
136
|
|
|
// initialize the params |
137
|
|
|
$params = array( |
138
|
|
|
$this->getPrimaryKeyMemberName() => $pk, |
139
|
|
|
MemberNames::ALL_GROUPS => $allGroups, |
140
|
|
|
MemberNames::CUSTOMER_GROUP_ID => $customerGroupId, |
141
|
|
|
MemberNames::QTY => $qty, |
142
|
|
|
MemberNames::WEBSITE_ID => $websiteId |
143
|
|
|
); |
144
|
|
|
|
145
|
|
|
// load and return the tier price with the passed params |
146
|
|
|
$this->tierPriceByPkAndAllGroupsAndCustomerGroupIdAndQtyAndWebsiteIdStmt->execute($params); |
147
|
|
|
return $this->tierPriceByPkAndAllGroupsAndCustomerGroupIdAndQtyAndWebsiteIdStmt->fetch(\PDO::FETCH_ASSOC); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Returns an array with all the tier prices. |
152
|
|
|
* |
153
|
|
|
* @return array The tier prices |
154
|
|
|
*/ |
155
|
|
|
public function findAll() |
156
|
|
|
{ |
157
|
|
|
// load and return the tier prices |
158
|
|
|
$this->tierPricesStmt->execute(); |
159
|
|
|
return $this->tierPricesStmt->fetchAll(\PDO::FETCH_ASSOC); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths