Skip to content

Commit 5969415

Browse files
committed
MAGETWO-67240: Duplicate and broken products appear after import
1 parent 7d60ba8 commit 5969415

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,9 +1563,7 @@ protected function _saveProducts()
15631563
}
15641564
$rowScope = $this->getRowScope($rowData);
15651565

1566-
if (empty($rowData[self::URL_KEY])) {
1567-
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
1568-
}
1566+
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
15691567

15701568
$rowSku = $rowData[self::COL_SKU];
15711569

@@ -2475,7 +2473,7 @@ public function validateRow(array $rowData, $rowNum)
24752473
$this->getOptionEntity()->validateRow($rowData, $rowNum);
24762474

24772475
if ($this->isNeedToValidateUrlKey($rowData)) {
2478-
$urlKey = $this->getUrlKey($rowData);
2476+
$urlKey = strtolower($this->getUrlKey($rowData));
24792477
$storeCodes = empty($rowData[self::COL_STORE_VIEW_CODE])
24802478
? array_flip($this->storeResolver->getStoreCodeToId())
24812479
: explode($this->getMultipleValueSeparator(), $rowData[self::COL_STORE_VIEW_CODE]);
@@ -2484,9 +2482,9 @@ public function validateRow(array $rowData, $rowNum)
24842482
$productUrlSuffix = $this->getProductUrlSuffix($storeId);
24852483
$urlPath = $urlKey . $productUrlSuffix;
24862484
if (empty($this->urlKeys[$storeId][$urlPath])
2487-
|| ($this->urlKeys[$storeId][$urlPath] == strtolower($sku))
2485+
|| ($this->urlKeys[$storeId][$urlPath] == $sku)
24882486
) {
2489-
$this->urlKeys[$storeId][$urlPath] = strtolower($sku);
2487+
$this->urlKeys[$storeId][$urlPath] = $sku;
24902488
$this->rowNumbers[$storeId][$urlPath] = $rowNum;
24912489
} else {
24922490
$message = sprintf(
@@ -2812,7 +2810,7 @@ protected function getProductUrlSuffix($storeId = null)
28122810
protected function getUrlKey($rowData)
28132811
{
28142812
if (!empty($rowData[self::URL_KEY])) {
2815-
return $rowData[self::URL_KEY];
2813+
return strtolower($rowData[self::URL_KEY]);
28162814
}
28172815

28182816
if (!empty($rowData[self::COL_NAME])) {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
sku,product_type,store_view_code,name,price,attribute_set_code,categories
2-
simPLE1,simple,,"simple 1",111,Default,"Default Category/Category 1"
3-
SIMPLE2,simple,,"simple 2",111,Default,"Default Category/Category 1"
4-
Simple3,simple,,"simple 3",111,Default,"Default Category/Category 1"
5-
SiMPle3,simple,,"simple 3",333,Default,"Default Category/Category 1"
6-
SIMplE2,simple,,"simple 2",222,Default,"Default Category/Category 1"
1+
sku,product_type,store_view_code,name,price,attribute_set_code,categories,url_key
2+
simPLE1,simple,,"simple 1",111,Default,"Default Category/Category 1","simple1"
3+
SIMPLE2,simple,,"simple 2",111,Default,"Default Category/Category 1","simpLE22"
4+
Simple3,simple,,"simple 3",111,Default,"Default Category/Category 1","simpLE33"
5+
SiMPle3,simple,,"simple 3",333,Default,"Default Category/Category 1","siMPle3"
6+
SIMplE2,simple,,"simple 2",222,Default,"Default Category/Category 1","siMPle2"

0 commit comments

Comments
 (0)