Skip to content

CSV product import does not format url key when url_key column is used #32911

Closed
@rikwillems

Description

@rikwillems

When I use the Magento default csv product import with an url_key field the value is not formatted/translit before being inserted into the database. This way I end up with spaces in the url key field. The rest of the system works ok with this except GraphQL which will output the url_key field directly from the database.

Preconditions (*)

Magento 2.4.2 and probably all versions below.

Steps to reproduce (*)

  1. Create a product with sku: ABC
  2. Import csv below:
"sku", "url_key"
"ABC", "Test ABC 1 2 3"

Expected result (*)

  1. url_key attribute being: test-abc-1-2-3

Actual result (*)

  1. url_key attribute being: test abc 1 2 3

  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.

Patch

--- vendor/magento/module-catalog-import-export/Model/Import/Product.php
+++ vendor/magento/module-catalog-import-export/Model/Import/Product.php
@@ -3011,7 +3011,7 @@
     {
         if (!empty($rowData[self::URL_KEY])) {
             $urlKey = (string) $rowData[self::URL_KEY];
-            return trim(strtolower($urlKey));
+            return $this->productUrl->formatUrlKey($urlKey);
         }
 
         if (!empty($rowData[self::COL_NAME])

Metadata

Metadata

Assignees

Labels

Component: ImportExportFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions