Skip to content

Product Import -> Missing categories entry in importfile removes url rewrites #18269

Closed
@ulftietze

Description

@ulftietze

Preconditions

  1. Magento 2.2.X | probably 2.3 as well
  2. PHP 7.0 | 7.1
  3. Would be nice to have 2 or more websites

Steps to reproduce

  1. Shop contains an existing product with at least following informations:
sku categories url_key product_websites
123456789 Default Category/ExistingCategory1,Default Category/ExistingCategory2 custom-url-key-for-product-123456789 de,at

Attributes like: name | price | url_key | attribute_set_code doesnt matter here.
Actually only interesting point here is: product_websites, but im going to explain later

  1. URL Rewrite contains following informations, because first time everything was imported successfully and completely:
url_rewrite_id entity_type entity_id request_path target_path redirect_type store_id description is_autogenerated metadata
1 product 1 custom-url-key-for-product-123456789/ catalog/product/view/id/1 0 1 NULL 1 NULL
2 product 1 custom-url-key-for-product-123456789/ catalog/product/view/id/1 0 2 NULL 1 NULL
3 product 1 existingcategory1/custom-url-key-for-product-123456789/ catalog/product/view/id/1/category/1 0 1 NULL 1 {"category_id":"1"}
4 product 1 existingcategory1/custom-url-key-for-product-123456789/ catalog/product/view/id/1/category/1 0 2 NULL 1 {"category_id":"1"}
5 product 1 existingcategory2/custom-url-key-for-product-123456789/ catalog/product/view/id/1/category/2 0 1 NULL 1 {"category_id":"2"}
6 product 1 existingcategory2/custom-url-key-for-product-123456789/ catalog/product/view/id/1/category/2 0 2 NULL 1 {"category_id":"2"}
  1. Import csv with following information (just removed the category information)
sku url_key product_websites store_view_code
123456789 custom-url-key-for-product-123456789 de,at
123456789 custom-url-key-for-product-123456789-de de
123456789 custom-url-key-for-product-123456789-at at
  1. This also works with following csv
  2. Import csv with following information (just removed the category information)
sku url_key product_websites
123456789 custom-url-key-for-product-123456789 de,at

Expected result

  1. The Url Rewrite Table looks the same as before, because we doesn't change any categories and wanted them inside too!

Actual result

  1. Just the follwing information are inside of the url_rewrite table:
url_rewrite_id entity_type entity_id request_path target_path redirect_type store_id description is_autogenerated metadata
1 product 1 custom-url-key-for-product-123456789/ catalog/product/view/id/1 0 1 NULL 1 NULL
2 product 1 custom-url-key-for-product-123456789/ catalog/product/view/id/1 0 2 NULL 1 NULL

Conclusion:

So if you provide an url key but no categories, Magento deletes the existing category url rewrites.
One missing point:

  • if you forgot to provide product_websites in your csv file, no url_rewrite is generated or updated. This behavior may be here by default, but i think it's better to renew all information about if the url_key has changed.

Greetz,
Ulf

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions