Skip to content

Commit f31f70d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-95101' into 2.2-develop-pr47
2 parents 1118adc + 8e526f5 commit f31f70d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2716,7 +2716,7 @@ protected function getProductUrlSuffix($storeId = null)
27162716
protected function getUrlKey($rowData)
27172717
{
27182718
if (!empty($rowData[self::URL_KEY])) {
2719-
return strtolower($rowData[self::URL_KEY]);
2719+
return $this->productUrl->formatUrlKey($rowData[self::URL_KEY]);
27202720
}
27212721

27222722
if (!empty($rowData[self::COL_NAME])) {

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,43 @@ public function testImportWithoutUrlKeys()
16031603
}
16041604
}
16051605

1606+
/**
1607+
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
1608+
* @magentoDbIsolation disabled
1609+
* @magentoAppIsolation enabled
1610+
* @return void
1611+
*/
1612+
public function testImportWithUrlKeysWithSpaces()
1613+
{
1614+
$products = [
1615+
'simple1' => 'url-key-with-spaces1',
1616+
'simple2' => 'url-key-with-spaces2',
1617+
];
1618+
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
1619+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
1620+
$source = $this->objectManager->create(
1621+
\Magento\ImportExport\Model\Import\Source\Csv::class,
1622+
[
1623+
'file' => __DIR__ . '/_files/products_to_import_with_url_keys_with_spaces.csv',
1624+
'directory' => $directory,
1625+
]
1626+
);
1627+
1628+
$errors = $this->_model->setParameters(
1629+
['behavior' => \Magento\ImportExport\Model\Import::BEHAVIOR_ADD_UPDATE, 'entity' => 'catalog_product']
1630+
)
1631+
->setSource($source)
1632+
->validateData();
1633+
1634+
$this->assertTrue($errors->getErrorsCount() == 0);
1635+
$this->_model->importData();
1636+
1637+
$productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
1638+
foreach ($products as $productSku => $productUrlKey) {
1639+
$this->assertEquals($productUrlKey, $productRepository->get($productSku)->getUrlKey());
1640+
}
1641+
}
1642+
16061643
/**
16071644
* @magentoAppIsolation enabled
16081645
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sku,product_type,store_view_code,name,price,attribute_set_code,url_key
2+
simple1,simple,,"simple1",50,Default,url key with spaces1
3+
simple2,simple,,"simple2",55,Default,url key with spaces2

0 commit comments

Comments
 (0)