@@ -925,7 +925,7 @@ protected function _deleteProducts()
925
925
926
926
foreach ($ bunch as $ rowNum => $ rowData ) {
927
927
if ($ this ->validateRow ($ rowData , $ rowNum ) && self ::SCOPE_DEFAULT == $ this ->getRowScope ($ rowData )) {
928
- $ idsToDelete [] = $ this ->_oldSku [$ rowData [self ::COL_SKU ]]['entity_id ' ];
928
+ $ idsToDelete [] = $ this ->_oldSku [strtolower ( $ rowData [self ::COL_SKU ]) ]['entity_id ' ];
929
929
}
930
930
}
931
931
if ($ idsToDelete ) {
@@ -1115,7 +1115,7 @@ protected function _prepareRowForDb(array $rowData)
1115
1115
1116
1116
$ lastSku = $ rowData [self ::COL_SKU ];
1117
1117
1118
- if (isset ($ this ->_oldSku [$ lastSku ])) {
1118
+ if (isset ($ this ->_oldSku [strtolower ( $ lastSku) ])) {
1119
1119
$ newSku = $ this ->skuProcessor ->getNewSku ($ lastSku );
1120
1120
$ rowData [self ::COL_ATTR_SET ] = $ newSku ['attr_set_code ' ];
1121
1121
$ rowData [self ::COL_TYPE ] = $ newSku ['type_id ' ];
@@ -1195,7 +1195,7 @@ protected function _saveLinks()
1195
1195
if (!empty ($ newSku )) {
1196
1196
$ linkedId = $ newSku ['entity_id ' ];
1197
1197
} else {
1198
- $ linkedId = $ this ->_oldSku [$ linkedSku ]['entity_id ' ];
1198
+ $ linkedId = $ this ->_oldSku [strtolower ( $ linkedSku) ]['entity_id ' ];
1199
1199
}
1200
1200
1201
1201
if ($ linkedId == null ) {
@@ -1396,7 +1396,7 @@ private function updateOldSku(array $newProducts)
1396
1396
$ oldSkus = [];
1397
1397
foreach ($ newProducts as $ info ) {
1398
1398
$ typeId = $ info ['type_id ' ];
1399
- $ sku = $ info ['sku ' ];
1399
+ $ sku = strtolower ( $ info ['sku ' ]) ;
1400
1400
$ oldSkus [$ sku ] = [
1401
1401
'type_id ' => $ typeId ,
1402
1402
'attr_set_id ' => $ info ['attribute_set_id ' ],
@@ -1455,7 +1455,7 @@ protected function getExistingImages($bunch)
1455
1455
}
1456
1456
1457
1457
$ this ->initMediaGalleryResources ();
1458
- $ productSKUs = array_map ('strval ' , array_column ($ bunch , self ::COL_SKU ));
1458
+ $ productSKUs = array_map ('strtolower ' , array_column ($ bunch , self ::COL_SKU ));
1459
1459
$ select = $ this ->_connection ->select ()->from (
1460
1460
['mg ' => $ this ->mediaGalleryTableName ],
1461
1461
['value ' => 'mg.value ' ]
@@ -1582,7 +1582,7 @@ protected function _saveProducts()
1582
1582
}
1583
1583
1584
1584
// 1. Entity phase
1585
- if (isset ($ this ->_oldSku [$ rowSku ])) {
1585
+ if (isset ($ this ->_oldSku [strtolower ( $ rowSku) ])) {
1586
1586
// existing row
1587
1587
if (isset ($ rowData ['attribute_set_code ' ])) {
1588
1588
$ attributeSetId = $ this ->catalogConfig ->getAttributeSetId (
@@ -1606,14 +1606,14 @@ protected function _saveProducts()
1606
1606
$ entityRowsUp [] = [
1607
1607
'updated_at ' => (new \DateTime ())->format (DateTime::DATETIME_PHP_FORMAT ),
1608
1608
'attribute_set_id ' => $ attributeSetId ,
1609
- $ this ->getProductEntityLinkField () => $ this ->_oldSku [$ rowSku ][$ this ->getProductEntityLinkField ()]
1609
+ $ this ->getProductEntityLinkField () => $ this ->_oldSku [strtolower ( $ rowSku) ][$ this ->getProductEntityLinkField ()]
1610
1610
];
1611
1611
} else {
1612
1612
if (!$ productLimit || $ productsQty < $ productLimit ) {
1613
1613
$ entityRowsIn [$ rowSku ] = [
1614
1614
'attribute_set_id ' => $ this ->skuProcessor ->getNewSku ($ rowSku )['attr_set_id ' ],
1615
1615
'type_id ' => $ this ->skuProcessor ->getNewSku ($ rowSku )['type_id ' ],
1616
- 'sku ' => $ rowSku ,
1616
+ 'sku ' => $ rowData [ self :: COL_SKU ] ,
1617
1617
'has_options ' => isset ($ rowData ['has_options ' ]) ? $ rowData ['has_options ' ] : 0 ,
1618
1618
'created_at ' => (new \DateTime ())->format (DateTime::DATETIME_PHP_FORMAT ),
1619
1619
'updated_at ' => (new \DateTime ())->format (DateTime::DATETIME_PHP_FORMAT ),
@@ -2192,7 +2192,8 @@ protected function _saveStockItem()
2192
2192
}
2193
2193
2194
2194
$ row = [];
2195
- $ row ['product_id ' ] = $ this ->skuProcessor ->getNewSku ($ rowData [self ::COL_SKU ])['entity_id ' ];
2195
+ $ sku = strtolower ($ rowData [self ::COL_SKU ]);
2196
+ $ row ['product_id ' ] = $ this ->skuProcessor ->getNewSku ($ sku )['entity_id ' ];
2196
2197
$ productIdsToReindex [] = $ row ['product_id ' ];
2197
2198
2198
2199
$ row ['website_id ' ] = $ this ->stockConfiguration ->getDefaultScopeId ();
@@ -2209,7 +2210,7 @@ protected function _saveStockItem()
2209
2210
);
2210
2211
2211
2212
if ($ this ->stockConfiguration ->isQty (
2212
- $ this ->skuProcessor ->getNewSku ($ rowData [ self :: COL_SKU ] )['type_id ' ]
2213
+ $ this ->skuProcessor ->getNewSku ($ sku )['type_id ' ]
2213
2214
)) {
2214
2215
$ stockItemDo ->setData ($ row );
2215
2216
$ row ['is_in_stock ' ] = $ this ->stockStateProvider ->verifyStock ($ stockItemDo );
@@ -2224,8 +2225,8 @@ protected function _saveStockItem()
2224
2225
} else {
2225
2226
$ row ['qty ' ] = 0 ;
2226
2227
}
2227
- if (!isset ($ stockData [$ rowData [ self :: COL_SKU ] ])) {
2228
- $ stockData [$ rowData [ self :: COL_SKU ] ] = $ row ;
2228
+ if (!isset ($ stockData [$ sku ])) {
2229
+ $ stockData [$ sku ] = $ row ;
2229
2230
}
2230
2231
}
2231
2232
@@ -2305,6 +2306,9 @@ public function getEntityTypeCode()
2305
2306
/**
2306
2307
* New products SKU data.
2307
2308
*
2309
+ * Returns array of new products data with SKU as key. All SKU keys are in lowercase for avoiding creation of
2310
+ * new products with the same SKU in different letter cases.
2311
+ *
2308
2312
* @var string $sku
2309
2313
* @return array
2310
2314
*/
@@ -2326,6 +2330,9 @@ public function getNextBunch()
2326
2330
/**
2327
2331
* Existing products SKU getter.
2328
2332
*
2333
+ * Returns array of existing products data with SKU as key. All SKU keys are in lowercase for avoiding creation of
2334
+ * new products with the same SKU in different letter cases.
2335
+ *
2329
2336
* @return array
2330
2337
*/
2331
2338
public function getOldSku ()
@@ -2376,16 +2383,17 @@ public function validateRow(array $rowData, $rowNum)
2376
2383
$ this ->_validatedRows [$ rowNum ] = true ;
2377
2384
2378
2385
$ rowScope = $ this ->getRowScope ($ rowData );
2386
+ $ sku = strtolower ($ rowData [self ::COL_SKU ]);
2379
2387
2380
2388
// BEHAVIOR_DELETE and BEHAVIOR_REPLACE use specific validation logic
2381
2389
if (Import::BEHAVIOR_REPLACE == $ this ->getBehavior ()) {
2382
- if (self ::SCOPE_DEFAULT == $ rowScope && !isset ($ this ->_oldSku [$ rowData [ self :: COL_SKU ] ])) {
2390
+ if (self ::SCOPE_DEFAULT == $ rowScope && !isset ($ this ->_oldSku [$ sku ])) {
2383
2391
$ this ->addRowError (ValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE , $ rowNum );
2384
2392
return false ;
2385
2393
}
2386
2394
}
2387
2395
if (Import::BEHAVIOR_DELETE == $ this ->getBehavior ()) {
2388
- if (self ::SCOPE_DEFAULT == $ rowScope && !isset ($ this ->_oldSku [$ rowData [ self :: COL_SKU ] ])) {
2396
+ if (self ::SCOPE_DEFAULT == $ rowScope && !isset ($ this ->_oldSku [$ sku ])) {
2389
2397
$ this ->addRowError (ValidatorInterface::ERROR_SKU_NOT_FOUND_FOR_DELETE , $ rowNum );
2390
2398
return false ;
2391
2399
}
@@ -2398,10 +2406,9 @@ public function validateRow(array $rowData, $rowNum)
2398
2406
}
2399
2407
}
2400
2408
2401
- $ sku = $ rowData [self ::COL_SKU ];
2402
- if (null === $ sku ) {
2409
+ if (null === $ rowData [self ::COL_SKU ]) {
2403
2410
$ this ->addRowError (ValidatorInterface::ERROR_SKU_IS_EMPTY , $ rowNum );
2404
- } elseif (false === $ sku ) {
2411
+ } elseif (false === $ rowData [ self :: COL_SKU ] ) {
2405
2412
$ this ->addRowError (ValidatorInterface::ERROR_ROW_IS_ORPHAN , $ rowNum );
2406
2413
} elseif (self ::SCOPE_STORE == $ rowScope
2407
2414
&& !$ this ->storeResolver ->getStoreCodeToId ($ rowData [self ::COL_STORE ])
@@ -2412,8 +2419,6 @@ public function validateRow(array $rowData, $rowNum)
2412
2419
// SKU is specified, row is SCOPE_DEFAULT, new product block begins
2413
2420
$ this ->_processedEntitiesCount ++;
2414
2421
2415
- $ sku = $ rowData [self ::COL_SKU ];
2416
-
2417
2422
if (isset ($ this ->_oldSku [$ sku ]) && Import::BEHAVIOR_REPLACE !== $ this ->getBehavior ()) {
2418
2423
// can we get all necessary data from existent DB product?
2419
2424
// check for supported type of existing product
@@ -2486,9 +2491,9 @@ public function validateRow(array $rowData, $rowNum)
2486
2491
$ productUrlSuffix = $ this ->getProductUrlSuffix ($ storeId );
2487
2492
$ urlPath = $ urlKey . $ productUrlSuffix ;
2488
2493
if (empty ($ this ->urlKeys [$ storeId ][$ urlPath ])
2489
- || ($ this ->urlKeys [$ storeId ][$ urlPath ] == $ rowData [ self :: COL_SKU ] )
2494
+ || ($ this ->urlKeys [$ storeId ][$ urlPath ] == $ sku )
2490
2495
) {
2491
- $ this ->urlKeys [$ storeId ][$ urlPath ] = $ rowData [ self :: COL_SKU ] ;
2496
+ $ this ->urlKeys [$ storeId ][$ urlPath ] = $ sku ;
2492
2497
$ this ->rowNumbers [$ storeId ][$ urlPath ] = $ rowNum ;
2493
2498
} else {
2494
2499
$ message = sprintf (
0 commit comments