This is strange bug in Magento.
This will happened - if URL-key exist in Magento,
and if Product name exist in Magento.
If each Products will with Unique Name - will be all OK.
Becouse URL-key based in Product name.
This very strange logic by Magento.
So,
for fix this bug need to edit file
vendor/magento/module-catalog-import-export/Model/Import/Product.php
1) change isNeedToValidateUrlKey
private function isNeedToValidateUrlKey($rowData)
{
return (!empty($rowData[self::URL_KEY]))
&& (empty($rowData[self::COL_VISIBILITY])
|| $rowData[self::COL_VISIBILITY]
!== (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]);
}
2) change getUrlKey
protected function getUrlKey($rowData)
{
if (!empty($rowData[self::URL_KEY])) {
return strtolower($rowData[self::URL_KEY]);
}
if (!empty($rowData[self::COL_NAME])) {
return $this->productUrl->formatUrlKey($rowData[self::COL_NAME].'-'.$rowData[self::COL_SKU]);
}
return '';
}
3) change _saveProducts -
cut code - $rowData[self::URL_KEY] = $this->getUrlKey($rowData);
and insert under - $rowSku = $rowData[self::COL_SKU];
following code
if ($this->isSkuExist($rowSku)) {
if (!empty($rowData[self::URL_KEY])) {
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
} else {
}
} else {
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
}
Now if in import CSV file - not exist column url_key,
will set url_key like ProductName-ProductSku
And without bugs :)