Description
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 (*)
- Install a fresh Magento instance
- Create
che
website withde_ch
,en_ch
,es_ch
,fr_ch
,zh_ch
store views - Create
exp
website withde_ex
,en_ex
,es_ex
,fr_ex
,zh_ex
store views - Create the
Products
category - Go on the admin panel under System > Import
- Choose Products entity type with Add/Update behaviour and let default settings for the rest
- Upload this file and launch the import
- General system exception happened
- Make the PR changes
- Repeat steps 5 to 7
- 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
Type
Projects
Status