Skip to content

Commit 27d7f5d

Browse files
committed
MAGETWO-67240: Duplicate and broken products appear after import
1 parent 7ab810b commit 27d7f5d

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,9 +2480,9 @@ public function validateRow(array $rowData, $rowNum)
24802480
$productUrlSuffix = $this->getProductUrlSuffix($storeId);
24812481
$urlPath = $urlKey . $productUrlSuffix;
24822482
if (empty($this->urlKeys[$storeId][$urlPath])
2483-
|| ($this->urlKeys[$storeId][$urlPath] == $sku)
2483+
|| ($this->urlKeys[$storeId][$urlPath] == strtolower($sku))
24842484
) {
2485-
$this->urlKeys[$storeId][$urlPath] = $sku;
2485+
$this->urlKeys[$storeId][$urlPath] = strtolower($sku);
24862486
$this->rowNumbers[$storeId][$urlPath] = $rowNum;
24872487
} else {
24882488
$message = sprintf(

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,9 +1810,9 @@ public function testImportWithDifferentSkuCase()
18101810
'simple3' => 58,
18111811
];
18121812
$updatedPrices = [
1813-
'simple1' => 999,
1814-
'simple2' => 999,
1815-
'simple3' => 999,
1813+
'simple1' => 111,
1814+
'simple2' => 222,
1815+
'simple3' => 333,
18161816
];
18171817

18181818
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
@@ -1838,6 +1838,10 @@ public function testImportWithDifferentSkuCase()
18381838

18391839
$this->_model->importData();
18401840

1841+
$this->assertEquals(
1842+
3,
1843+
count($productRepository->getList($searchCriteria)->getItems())
1844+
);
18411845
foreach ($importedPrices as $sku => $expectedPrice) {
18421846
$this->assertEquals($expectedPrice, $productRepository->get($sku)->getPrice());
18431847
}
@@ -1860,6 +1864,11 @@ public function testImportWithDifferentSkuCase()
18601864

18611865
$this->_model->importData();
18621866

1867+
$this->assertEquals(
1868+
3,
1869+
count($productRepository->getList($searchCriteria)->getItems()),
1870+
'Ensures that new products were not created'
1871+
);
18631872
foreach ($updatedPrices as $sku => $expectedPrice) {
18641873
$this->assertEquals(
18651874
$expectedPrice,
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
sku,product_type,store_view_code,name,price,attribute_set_code,categories
2-
simPLE1,simple,,"simple 1",999,Default,"Default Category/Category 1"
3-
SIMPLE2,simple,,"simple 2",999,Default,"Default Category/Category 1"
4-
Simple3,simple,,"simple 3",999,Default,"Default Category/Category 1"
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"

0 commit comments

Comments
 (0)