|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Spryker Commerce OS. |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Pyz\Zed\ExampleProductSalePage\Persistence; |
|
9
|
|
|
|
|
10
|
|
|
use Orm\Zed\Product\Persistence\SpyProductAbstractQuery; |
|
11
|
|
|
use Orm\Zed\ProductLabel\Persistence\Map\SpyProductLabelProductAbstractTableMap; |
|
|
|
|
|
|
12
|
|
|
use Orm\Zed\ProductLabel\Persistence\SpyProductLabelProductAbstractQuery; |
|
13
|
|
|
use Orm\Zed\ProductLabel\Persistence\SpyProductLabelQuery; |
|
14
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
|
15
|
|
|
use Propel\Runtime\ActiveQuery\Criterion\BasicModelCriterion; |
|
16
|
|
|
use Spryker\Zed\Kernel\Persistence\AbstractQueryContainer; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @method \Pyz\Zed\ExampleProductSalePage\Persistence\ExampleProductSalePagePersistenceFactory getFactory() |
|
20
|
|
|
*/ |
|
21
|
|
|
class ExampleProductSalePageQueryContainer extends AbstractQueryContainer implements ExampleProductSalePageQueryContainerInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
protected const PRICE_TYPE_ORIGINAL = 'ORIGINAL'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @uses \Spryker\Shared\PriceProduct\PriceProductConfig::PRICE_TYPE_DEFAULT |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
protected const PRICE_TYPE_DEFAULT = 'DEFAULT'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @uses \Spryker\Shared\Price\PriceConfig::PRICE_MODE_NET |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected const PRICE_MODE_NET = 'NET_MODE'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @uses \Spryker\Shared\Price\PriceConfig::PRICE_MODE_GROSS |
|
44
|
|
|
* |
|
45
|
|
|
* @var string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected const PRICE_MODE_GROSS = 'GROSS_MODE'; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @api |
|
51
|
|
|
* |
|
52
|
|
|
* @param string $labelName |
|
53
|
|
|
* |
|
54
|
|
|
* @return \Orm\Zed\ProductLabel\Persistence\SpyProductLabelQuery |
|
55
|
|
|
*/ |
|
56
|
|
|
public function queryProductLabelByName($labelName): SpyProductLabelQuery |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->getFactory() |
|
|
|
|
|
|
59
|
|
|
->getProductLabelQueryContainer() |
|
60
|
|
|
->queryProductLabelByName($labelName); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @api |
|
65
|
|
|
* |
|
66
|
|
|
* @param int $idProductLabel |
|
67
|
|
|
* @param string $priceMode |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Orm\Zed\ProductLabel\Persistence\SpyProductLabelProductAbstractQuery |
|
70
|
|
|
*/ |
|
71
|
|
|
public function queryRelationsBecomingInactive(int $idProductLabel, string $priceMode): SpyProductLabelProductAbstractQuery |
|
72
|
|
|
{ |
|
73
|
|
|
/** @var \Orm\Zed\ProductLabel\Persistence\SpyProductLabelProductAbstractQuery $productLabelProductAbstractQuery */ |
|
74
|
|
|
$productLabelProductAbstractQuery = $this->getFactory() |
|
75
|
|
|
->getProductLabelQueryContainer() |
|
76
|
|
|
->queryProductAbstractRelationsByIdProductLabel($idProductLabel) |
|
77
|
|
|
->distinct() |
|
78
|
|
|
->useSpyProductAbstractQuery(null, Criteria::LEFT_JOIN) |
|
79
|
|
|
->usePriceProductQuery('priceProductOrigin', Criteria::LEFT_JOIN) |
|
80
|
|
|
->joinPriceType('priceTypeOrigin', Criteria::INNER_JOIN) |
|
81
|
|
|
->addJoinCondition( |
|
82
|
|
|
'priceTypeOrigin', |
|
83
|
|
|
'priceTypeOrigin.name = ?', |
|
84
|
|
|
static::PRICE_TYPE_ORIGINAL, |
|
85
|
|
|
) |
|
86
|
|
|
->usePriceProductStoreQuery('priceProductStoreOrigin', Criteria::LEFT_JOIN) |
|
87
|
|
|
->usePriceProductDefaultQuery('priceProductDefaultOriginal', Criteria::LEFT_JOIN) |
|
88
|
|
|
->endUse() |
|
89
|
|
|
->endUse() |
|
90
|
|
|
->endUse() |
|
91
|
|
|
->usePriceProductQuery('priceProductDefault', Criteria::LEFT_JOIN) |
|
92
|
|
|
->joinPriceType('priceTypeDefault', Criteria::INNER_JOIN) |
|
93
|
|
|
->addJoinCondition( |
|
94
|
|
|
'priceTypeDefault', |
|
95
|
|
|
'priceTypeDefault.name = ?', |
|
96
|
|
|
static::PRICE_TYPE_DEFAULT, |
|
97
|
|
|
) |
|
98
|
|
|
->usePriceProductStoreQuery('priceProductStoreDefault', Criteria::LEFT_JOIN) |
|
99
|
|
|
->usePriceProductDefaultQuery('priceProductDefaultDefault', Criteria::LEFT_JOIN) |
|
100
|
|
|
->endUse() |
|
101
|
|
|
->endUse() |
|
102
|
|
|
->endUse() |
|
103
|
|
|
->endUse() |
|
104
|
|
|
->addAnd('priceProductDefaultOriginal.id_price_product_default', null, Criteria::ISNOTNULL) |
|
105
|
|
|
->addAnd('priceProductDefaultDefault.id_price_product_default', null, Criteria::ISNOTNULL) |
|
106
|
|
|
->addJoinCondition('priceProductStoreDefault', 'priceProductStoreOrigin.fk_store = priceProductStoreDefault.fk_store') |
|
107
|
|
|
->addJoinCondition('priceProductStoreDefault', 'priceProductStoreOrigin.fk_currency = priceProductStoreDefault.fk_currency'); |
|
108
|
|
|
|
|
109
|
|
|
if ($priceMode === static::PRICE_MODE_GROSS) { |
|
110
|
|
|
$productLabelProductAbstractQuery->addAnd( |
|
111
|
|
|
$this->getBasicModelCriterion( |
|
112
|
|
|
$productLabelProductAbstractQuery, |
|
113
|
|
|
'priceProductStoreOrigin.gross_price < priceProductStoreDefault.gross_price', |
|
114
|
|
|
'priceProductStoreOrigin.gross_price', |
|
115
|
|
|
), |
|
116
|
|
|
) |
|
117
|
|
|
->addOr( |
|
118
|
|
|
$this->getBasicModelCriterion( |
|
119
|
|
|
$productLabelProductAbstractQuery, |
|
120
|
|
|
'priceProductStoreOrigin.gross_price = priceProductStoreDefault.gross_price', |
|
121
|
|
|
'priceProductStoreOrigin.gross_price', |
|
122
|
|
|
), |
|
123
|
|
|
) |
|
124
|
|
|
->addOr($productLabelProductAbstractQuery->getNewCriterion('priceProductStoreOrigin.gross_price', null, Criteria::ISNULL) |
|
125
|
|
|
->addOr($productLabelProductAbstractQuery->getNewCriterion('priceProductStoreDefault.gross_price', null, Criteria::ISNULL))); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
if ($priceMode === static::PRICE_MODE_NET) { |
|
129
|
|
|
$productLabelProductAbstractQuery->addAnd( |
|
130
|
|
|
$this->getBasicModelCriterion( |
|
131
|
|
|
$productLabelProductAbstractQuery, |
|
132
|
|
|
'priceProductStoreOrigin.net_price < priceProductStoreDefault.net_price', |
|
133
|
|
|
'priceProductStoreOrigin.net_price', |
|
134
|
|
|
), |
|
135
|
|
|
) |
|
136
|
|
|
->addOr( |
|
137
|
|
|
$this->getBasicModelCriterion( |
|
138
|
|
|
$productLabelProductAbstractQuery, |
|
139
|
|
|
'priceProductStoreOrigin.net_price = priceProductStoreDefault.net_price', |
|
140
|
|
|
'priceProductStoreOrigin.net_price', |
|
141
|
|
|
), |
|
142
|
|
|
) |
|
143
|
|
|
->addOr($productLabelProductAbstractQuery->getNewCriterion('priceProductStoreOrigin.net_price', null, Criteria::ISNULL) |
|
144
|
|
|
->addAnd($productLabelProductAbstractQuery->getNewCriterion('priceProductStoreDefault.net_price', null, Criteria::ISNULL))); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
return $productLabelProductAbstractQuery; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* @param \Propel\Runtime\ActiveQuery\Criteria $criteria |
|
152
|
|
|
* @param string $clause |
|
153
|
|
|
* @param \Propel\Runtime\Map\ColumnMap|string $column |
|
154
|
|
|
* |
|
155
|
|
|
* @return \Propel\Runtime\ActiveQuery\Criterion\BasicModelCriterion |
|
156
|
|
|
*/ |
|
157
|
|
|
protected function getBasicModelCriterion(Criteria $criteria, string $clause, $column): BasicModelCriterion |
|
158
|
|
|
{ |
|
159
|
|
|
return new BasicModelCriterion($criteria, $clause, $column); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @api |
|
164
|
|
|
* |
|
165
|
|
|
* @param int $idProductLabel |
|
166
|
|
|
* @param int $currentStoreId |
|
167
|
|
|
* @param int $currentCurrencyId |
|
168
|
|
|
* @param string $priceMode |
|
169
|
|
|
* |
|
170
|
|
|
* @return \Orm\Zed\Product\Persistence\SpyProductAbstractQuery |
|
171
|
|
|
*/ |
|
172
|
|
|
public function queryRelationsBecomingActive( |
|
173
|
|
|
int $idProductLabel, |
|
174
|
|
|
int $currentStoreId, |
|
175
|
|
|
int $currentCurrencyId, |
|
176
|
|
|
string $priceMode, |
|
177
|
|
|
): SpyProductAbstractQuery { |
|
178
|
|
|
/** @var \Orm\Zed\Product\Persistence\SpyProductAbstractQuery $productAbstractQuery */ |
|
179
|
|
|
$productAbstractQuery = $this->getFactory() |
|
180
|
|
|
->getProductQueryContainer() |
|
181
|
|
|
->queryProductAbstract() |
|
182
|
|
|
->distinct() |
|
183
|
|
|
->usePriceProductQuery('priceProductOrigin', Criteria::LEFT_JOIN) |
|
184
|
|
|
->joinPriceType('priceTypeOrigin', Criteria::INNER_JOIN) |
|
185
|
|
|
->addJoinCondition( |
|
186
|
|
|
'priceTypeOrigin', |
|
187
|
|
|
'priceTypeOrigin.name = ?', |
|
188
|
|
|
static::PRICE_TYPE_ORIGINAL, |
|
189
|
|
|
) |
|
190
|
|
|
->usePriceProductStoreQuery('priceProductStoreOrigin', Criteria::LEFT_JOIN) |
|
191
|
|
|
->usePriceProductDefaultQuery('priceProductDefaultOriginal', Criteria::LEFT_JOIN) |
|
192
|
|
|
->endUse() |
|
193
|
|
|
->endUse() |
|
194
|
|
|
->endUse() |
|
195
|
|
|
->usePriceProductQuery('priceProductDefault', Criteria::LEFT_JOIN) |
|
196
|
|
|
->joinPriceType('priceTypeDefault', Criteria::INNER_JOIN) |
|
197
|
|
|
->addJoinCondition( |
|
198
|
|
|
'priceTypeDefault', |
|
199
|
|
|
'priceTypeDefault.name = ?', |
|
200
|
|
|
static::PRICE_TYPE_DEFAULT, |
|
201
|
|
|
) |
|
202
|
|
|
->usePriceProductStoreQuery('priceProductStoreDefault', Criteria::LEFT_JOIN) |
|
203
|
|
|
->usePriceProductDefaultQuery('priceProductDefaultDefault', Criteria::LEFT_JOIN) |
|
204
|
|
|
->endUse() |
|
205
|
|
|
->endUse() |
|
206
|
|
|
->endUse() |
|
207
|
|
|
->useSpyProductLabelProductAbstractQuery('rel', Criteria::LEFT_JOIN) |
|
208
|
|
|
->endUse() |
|
209
|
|
|
->addJoin( |
|
210
|
|
|
['rel.fk_product_abstract', SpyProductLabelProductAbstractTableMap::COL_FK_PRODUCT_LABEL], |
|
211
|
|
|
[SpyProductLabelProductAbstractTableMap::COL_FK_PRODUCT_ABSTRACT, $idProductLabel], |
|
212
|
|
|
Criteria::LEFT_JOIN, |
|
213
|
|
|
) |
|
214
|
|
|
->addJoinCondition('priceProductStoreDefault', 'priceProductDefault.id_price_product=priceProductStoreDefault.fk_price_product') |
|
215
|
|
|
->addJoinCondition('priceProductStoreDefault', 'priceProductStoreOrigin.fk_store = priceProductStoreDefault.fk_store') |
|
216
|
|
|
->addJoinCondition('priceProductStoreDefault', 'priceProductStoreOrigin.fk_currency = priceProductStoreDefault.fk_currency'); |
|
217
|
|
|
|
|
218
|
|
|
$productAbstractQuery->addAnd(SpyProductLabelProductAbstractTableMap::COL_FK_PRODUCT_ABSTRACT, null, Criteria::ISNULL); |
|
219
|
|
|
$productAbstractQuery->addAnd('priceProductStoreOrigin.fk_store', $currentStoreId, Criteria::EQUAL); |
|
220
|
|
|
$productAbstractQuery->addAnd('priceProductStoreOrigin.fk_currency', $currentCurrencyId, Criteria::EQUAL); |
|
221
|
|
|
$productAbstractQuery->addAnd('priceProductStoreDefault.fk_store', $currentStoreId, Criteria::EQUAL); |
|
222
|
|
|
$productAbstractQuery->addAnd('priceProductStoreDefault.fk_currency', $currentCurrencyId, Criteria::EQUAL); |
|
223
|
|
|
|
|
224
|
|
|
if ($priceMode === static::PRICE_MODE_GROSS) { |
|
225
|
|
|
$productAbstractQuery->addAnd( |
|
226
|
|
|
$this->getBasicModelCriterion( |
|
227
|
|
|
$productAbstractQuery, |
|
228
|
|
|
'priceProductStoreOrigin.gross_price > priceProductStoreDefault.gross_price', |
|
229
|
|
|
'priceProductStoreOrigin.gross_price', |
|
230
|
|
|
), |
|
231
|
|
|
); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
if ($priceMode === static::PRICE_MODE_NET) { |
|
235
|
|
|
$productAbstractQuery->addAnd( |
|
236
|
|
|
$this->getBasicModelCriterion( |
|
237
|
|
|
$productAbstractQuery, |
|
238
|
|
|
'priceProductStoreOrigin.net_price > priceProductStoreDefault.net_price', |
|
239
|
|
|
'priceProductStoreOrigin.net_price', |
|
240
|
|
|
), |
|
241
|
|
|
); |
|
242
|
|
|
} |
|
243
|
|
|
|
|
244
|
|
|
return $productAbstractQuery; |
|
245
|
|
|
} |
|
246
|
|
|
} |
|
247
|
|
|
|
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