0

I have products on magento 2.4.0 now when I use product import (Add/Update & also replace) to update product data, it throws below error

Url key: 'this-is-product-url-key' was already generated for an item with the SKU: 'this-is-sku'. You need to specify the unique URL key manually in row(s):

In short I dont want to update url_key

I have tried adding field url_key with data in it(url_key which is already generated previously)

Also tried removing url_key field completely which is then throwing below error

The value specified in the URL Key field would generate a URL that already exists

& also tried adding field url_key with blank data

Can anyone please help looking into it.

2 Answers 2

0

Remove the url_key column from your CSV file and try the import again.

2
  • Thanks for the answer, but I already havent added url_key column in my csv, it still throws error Apr 19, 2021 at 13:52
  • roger that, i thought you had a full csv
    – Diana
    Apr 20, 2021 at 7:43
0

The check, that triggers this validation is in \Magento\CatalogImportExport\Model\Import\Product::isNeedToValidateUrlKey:

    /**
     * Check if need to validate url key.
     *
     * @param array $rowData
     * @return bool
     */
    private function isNeedToValidateUrlKey($rowData)
    {
        if (!empty($rowData[self::COL_SKU]) && empty($rowData[self::URL_KEY])
            && $this->getBehavior() === Import::BEHAVIOR_APPEND
            && $this->isSkuExist($rowData[self::COL_SKU])) {
            return false;
        }

        return (!empty($rowData[self::URL_KEY]) || !empty($rowData[self::COL_NAME]))
            && (empty($rowData[self::COL_VISIBILITY])
                || $rowData[self::COL_VISIBILITY]
                !== (string)Visibility::getOptionArray()[Visibility::VISIBILITY_NOT_VISIBLE]);
    }

So, if your CSV file contains name field the check will be triggered if item is visible or there is no visibility column.

To bypass this validation you could follow the first condition: CSV file should contain sku column, import behaviour should be append and product should be existed.

If you don't need to update product's name attribute try to remove this field from CSV file. This should help as well.

5
  • Thanks for the answer, but I am bit confused - SKU field is already there on CSV with values in it, should I now remove name field ? Visibility field is also not added on CSV Apr 19, 2021 at 9:47
  • updated comment with clarification
    – Alex
    Apr 19, 2021 at 11:11
  • I mean, In my csv SKU column is already there with its values & Name column field with its data is already there, I havent added visibility column, do you want me to add visibility column or you want me to remove name column? Apr 19, 2021 at 11:17
  • if you don't want to update name attribute feel free to remove it from CSV file. You could add visibility column, but to bypass the validation value should be Visibility::VISIBILITY_NOT_VISIBLE: 1. This will hide updated product from frontend
    – Alex
    Apr 19, 2021 at 11:22
  • 1st thing removing name coloum from csv thrown error= name cant be blank & 2nd I dont want to hide product from frontend, I want to update products but its throwing error which I mentioned in my question Apr 19, 2021 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.