@@ -143,21 +143,47 @@ private function retrieveValidPrices(array $prices)
143
143
$ this ->validationResult ->addFailedItem (
144
144
$ key ,
145
145
__ (
146
- 'Requested product doesn \'t exist: %sku ' ,
147
- ['sku ' => '%sku ' ]
146
+ 'Requested product doesn \'t exist. '
147
+ . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo. ' ,
148
+ [
149
+ 'SKU ' => $ price ->getSku (),
150
+ 'storeId ' => $ price ->getStoreId (),
151
+ 'priceFrom ' => $ price ->getPriceFrom (),
152
+ 'priceTo ' => $ price ->getPriceTo ()
153
+ ]
148
154
),
149
- ['sku ' => $ price ->getSku ()]
155
+ [
156
+ 'SKU ' => $ price ->getSku (),
157
+ 'storeId ' => $ price ->getStoreId (),
158
+ 'priceFrom ' => $ price ->getPriceFrom (),
159
+ 'priceTo ' => $ price ->getPriceTo ()
160
+ ]
150
161
);
151
162
}
152
- $ this ->checkPrice ($ price-> getPrice () , $ key );
153
- $ this ->checkDate ($ price ->getPriceFrom (), 'Price From ' , $ key );
154
- $ this ->checkDate ($ price ->getPriceTo (), 'Price To ' , $ key );
163
+ $ this ->checkPrice ($ price , $ key );
164
+ $ this ->checkDate ($ price, $ price ->getPriceFrom (), 'Price From ' , $ key );
165
+ $ this ->checkDate ($ price, $ price ->getPriceTo (), 'Price To ' , $ key );
155
166
try {
156
167
$ this ->storeRepository ->getById ($ price ->getStoreId ());
157
168
} catch (NoSuchEntityException $ e ) {
158
169
$ this ->validationResult ->addFailedItem (
159
170
$ key ,
160
- __ ('Requested store is not found. ' )
171
+ __ (
172
+ 'Requested store is not found. '
173
+ . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo. ' ,
174
+ [
175
+ 'SKU ' => $ price ->getSku (),
176
+ 'storeId ' => $ price ->getStoreId (),
177
+ 'priceFrom ' => $ price ->getPriceFrom (),
178
+ 'priceTo ' => $ price ->getPriceTo ()
179
+ ]
180
+ ),
181
+ [
182
+ 'SKU ' => $ price ->getSku (),
183
+ 'storeId ' => $ price ->getStoreId (),
184
+ 'priceFrom ' => $ price ->getPriceFrom (),
185
+ 'priceTo ' => $ price ->getPriceTo ()
186
+ ]
161
187
);
162
188
}
163
189
}
@@ -172,21 +198,35 @@ private function retrieveValidPrices(array $prices)
172
198
/**
173
199
* Check that date value is correct and add error to aggregator if it contains incorrect data.
174
200
*
201
+ * @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price
175
202
* @param string $value
176
203
* @param string $label
177
204
* @param int $key
178
205
* @return void
179
206
*/
180
- private function checkDate ($ value , $ label , $ key )
207
+ private function checkDate (\ Magento \ Catalog \ Api \ Data \ SpecialPriceInterface $ price , $ value , $ label , $ key )
181
208
{
182
209
if ($ value && !$ this ->isCorrectDateValue ($ value )) {
183
210
$ this ->validationResult ->addFailedItem (
184
211
$ key ,
185
212
__ (
186
- 'Invalid attribute %fieldName = %fieldValue. ' ,
187
- ['fieldName ' => '%fieldName ' , 'fieldValue ' => '%fieldValue ' ]
213
+ 'Invalid attribute %label = %priceTo. '
214
+ . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo. ' ,
215
+ [
216
+ 'label ' => $ label ,
217
+ 'SKU ' => $ price ->getSku (),
218
+ 'storeId ' => $ price ->getStoreId (),
219
+ 'priceFrom ' => $ price ->getPriceFrom (),
220
+ 'priceTo ' => $ price ->getPriceTo ()
221
+ ]
188
222
),
189
- ['fieldName ' => $ label , 'fieldValue ' => $ value ]
223
+ [
224
+ 'label ' => $ label ,
225
+ 'SKU ' => $ price ->getSku (),
226
+ 'storeId ' => $ price ->getStoreId (),
227
+ 'priceFrom ' => $ price ->getPriceFrom (),
228
+ 'priceTo ' => $ price ->getPriceTo ()
229
+ ]
190
230
);
191
231
}
192
232
}
@@ -195,35 +235,48 @@ private function checkDate($value, $label, $key)
195
235
* Check that provided price value is not empty and not lower then zero and add error to aggregator if price
196
236
* contains not valid data.
197
237
*
198
- * @param float $price
238
+ * @param \Magento\Catalog\Api\Data\SpecialPriceInterface $price
199
239
* @param int $key
200
240
* @return void
201
241
*/
202
- private function checkPrice ($ price , $ key )
242
+ private function checkPrice (\ Magento \ Catalog \ Api \ Data \ SpecialPriceInterface $ price , $ key )
203
243
{
204
- if (null === $ price || $ price < 0 ) {
244
+ if (null === $ price-> getPrice () || $ price-> getPrice () < 0 ) {
205
245
$ this ->validationResult ->addFailedItem (
206
246
$ key ,
207
247
__ (
208
- 'Invalid attribute %fieldName = %fieldValue. ' ,
209
- ['fieldName ' => '%fieldName ' , 'fieldValue ' => '%fieldValue ' ]
248
+ 'Invalid attribute Price = %price. '
249
+ . 'Row ID: SKU = %SKU, Store ID: %storeId, Price From: %priceFrom, Price To: %priceTo. ' ,
250
+ [
251
+ 'price ' => $ price ->getPrice (),
252
+ 'SKU ' => $ price ->getSku (),
253
+ 'storeId ' => $ price ->getStoreId (),
254
+ 'priceFrom ' => $ price ->getPriceFrom (),
255
+ 'priceTo ' => $ price ->getPriceTo ()
256
+ ]
210
257
),
211
- ['fieldName ' => 'Price ' , 'fieldValue ' => $ price ]
258
+ [
259
+ 'price ' => $ price ->getPrice (),
260
+ 'SKU ' => $ price ->getSku (),
261
+ 'storeId ' => $ price ->getStoreId (),
262
+ 'priceFrom ' => $ price ->getPriceFrom (),
263
+ 'priceTo ' => $ price ->getPriceTo ()
264
+ ]
212
265
);
213
266
}
214
267
}
215
268
216
269
/**
217
270
* Retrieve SKU by product ID.
218
271
*
219
- * @param int $id
272
+ * @param int $productId
220
273
* @param array $skus
221
- * @return int |null
274
+ * @return string |null
222
275
*/
223
- private function retrieveSkuById ($ id , array $ skus )
276
+ private function retrieveSkuById ($ productId , array $ skus )
224
277
{
225
278
foreach ($ this ->productIdLocator ->retrieveProductIdsBySkus ($ skus ) as $ sku => $ ids ) {
226
- if (false !== array_key_exists ( $ id , $ ids )) {
279
+ if (isset ( $ ids[ $ productId ] )) {
227
280
return $ sku ;
228
281
}
229
282
}
0 commit comments