@@ -119,6 +119,13 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
119
119
*/
120
120
protected $ _permanentAttributes = [self ::COL_SKU ];
121
121
122
+ /**
123
+ * Catalog product entity
124
+ *
125
+ * @var string
126
+ */
127
+ protected $ _catalogProductEntity ;
128
+
122
129
/**
123
130
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
124
131
* @param \Magento\Framework\Json\Helper\Data $jsonHelper
@@ -164,6 +171,7 @@ public function __construct(
164
171
$ this ->_oldSkus = $ this ->retrieveOldSkus ();
165
172
$ this ->websiteValidator = $ websiteValidator ;
166
173
$ this ->groupPriceValidator = $ groupPriceValidator ;
174
+ $ this ->_catalogProductEntity = $ this ->_resourceFactory ->create ()->getTable ('catalog_product_entity ' );
167
175
}
168
176
169
177
/**
@@ -262,6 +270,7 @@ public function deleteAdvancedPricing()
262
270
if ($ listSku ) {
263
271
$ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_GROUPED_PRICE );
264
272
$ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE );
273
+ $ this ->setUpdatedAt ($ listSku );
265
274
}
266
275
return $ this ;
267
276
}
@@ -298,9 +307,9 @@ protected function saveAndReplaceAdvancedPrices()
298
307
continue ;
299
308
}
300
309
$ rowSku = $ rowData [self ::COL_SKU ];
301
- if (\Magento \ImportExport \Model \Import::BEHAVIOR_REPLACE == $ behavior ) {
310
+ // if (\Magento\ImportExport\Model\Import::BEHAVIOR_REPLACE == $behavior) {
302
311
$ listSku [] = $ rowSku ;
303
- }
312
+ // }
304
313
if (!empty ($ rowData [self ::COL_TIER_PRICE_WEBSITE ])) {
305
314
$ tierPrices [$ rowSku ][] = [
306
315
'all_groups ' => $ rowData [self ::COL_TIER_PRICE_CUSTOMER_GROUP ] == self ::VALUE_ALL_GROUPS ,
@@ -330,6 +339,7 @@ protected function saveAndReplaceAdvancedPrices()
330
339
&& $ this ->deleteProductTierAndGroupPrices (array_unique ($ listSku ), self ::TABLE_TIER_PRICE )) {
331
340
$ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
332
341
->saveProductPrices ($ groupPrices , self ::TABLE_GROUPED_PRICE );
342
+ $ this ->setUpdatedAt ($ listSku );
333
343
}
334
344
}
335
345
} elseif (\Magento \ImportExport \Model \Import::BEHAVIOR_APPEND == $ behavior ) {
@@ -338,6 +348,9 @@ protected function saveAndReplaceAdvancedPrices()
338
348
->processCountNewPrices ($ tierPrices , $ groupPrices );
339
349
$ this ->saveProductPrices ($ tierPrices , self ::TABLE_TIER_PRICE )
340
350
->saveProductPrices ($ groupPrices , self ::TABLE_GROUPED_PRICE );
351
+ if ($ listSku ) {
352
+ $ this ->setUpdatedAt ($ listSku );
353
+ }
341
354
}
342
355
}
343
356
return $ this ;
@@ -355,12 +368,14 @@ protected function saveProductPrices(array $priceData, $table)
355
368
if ($ priceData ) {
356
369
$ tableName = $ this ->_resourceFactory ->create ()->getTable ($ table );
357
370
$ priceIn = [];
371
+ $ entityIds = [];
358
372
foreach ($ priceData as $ sku => $ priceRows ) {
359
373
if (isset ($ this ->_oldSkus [$ sku ])) {
360
374
$ productId = $ this ->_oldSkus [$ sku ];
361
375
foreach ($ priceRows as $ row ) {
362
376
$ row ['entity_id ' ] = $ productId ;
363
377
$ priceIn [] = $ row ;
378
+ $ entityIds [] = $ productId ;
364
379
}
365
380
}
366
381
}
@@ -384,7 +399,7 @@ protected function deleteProductTierAndGroupPrices(array $listSku, $tableName)
384
399
if (!$ this ->_cachedSkuToDelete ) {
385
400
$ this ->_cachedSkuToDelete = $ this ->_connection ->fetchCol (
386
401
$ this ->_connection ->select ()
387
- ->from ($ this ->_connection -> getTableName ( ' catalog_product_entity ' ) , 'entity_id ' )
402
+ ->from ($ this ->_catalogProductEntity , 'entity_id ' )
388
403
->where ('sku IN (?) ' , $ listSku )
389
404
);
390
405
}
@@ -407,6 +422,20 @@ protected function deleteProductTierAndGroupPrices(array $listSku, $tableName)
407
422
}
408
423
}
409
424
425
+ /**
426
+ * Set updated_at for product
427
+ *
428
+ * @param $listSku
429
+ */
430
+ protected function setUpdatedAt ($ listSku )
431
+ {
432
+ $ this ->_connection ->update (
433
+ $ this ->_catalogProductEntity ,
434
+ [\Magento \Catalog \Model \Category::KEY_UPDATED_AT => date ('Y-m-d H:i:s ' )],
435
+ $ this ->_connection ->quoteInto ('sku IN (?) ' , $ listSku )
436
+ );
437
+ }
438
+
410
439
/**
411
440
* Get website id by code
412
441
*
0 commit comments