Skip to content

[Issue] Ensure that previously existing records in catalog_url_rewrite_produc… #34210

Closed
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #34209: Ensure that previously existing records in catalog_url_rewrite_produc…


Ensure that previously existing records in catalog_url_rewrite_product_category are deleted before trying to insert them again.

Description (*)

Changes

Delete existing records in the catalog_url_rewrite_product_category table before inserting the same ones.

Why

This change will avoid the following exception during multi store product import :

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '74583' for key 'PRIMARY', query was: INSERT INTO catalog_url_rewrite_product_category (url_rewrite_id,category_id,product_id) VALUES (?, ?, ?), ...

The problem is that catalog_url_rewrite_product_category records are not created storewise for a given request_path. On the other side, url_rewrite records are created storewise.
If, during the same import, a product and its url_rewrite records are created for stores A and B in the first batch and then for store C in a second batch and if product url keys and category name are the same for all those stores, an insert try for duplicated catalog_url_rewrite_product_category records will cause the mentioned issue.

Related Pull Requests

None

Fixed Issues (if relevant)

Not relevant

Manual testing scenarios (*)

  1. Install a fresh Magento instance
  2. Create che website with de_ch, en_ch, es_ch, fr_ch, zh_ch store views
  3. Create exp website with de_ex, en_ex, es_ex, fr_ex, zh_ex store views
  4. Create the Products category
  5. Go on the admin panel under System > Import
  6. Choose Products entity type with Add/Update behaviour and let default settings for the rest
  7. Upload this file and launch the import
  8. General system exception happened
  9. Make the PR changes
  10. Repeat steps 5 to 7
  11. Import works fine

Questions or comments

I am not sure if an additional test is needed for that. Please, tell me if it is the case.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

Labels

Area: Import / exportComponent: CatalogUrlRewriteIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: ready for confirmationPriority: 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 branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions