Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Foreign Key / Cascade process for catalog_category_product_index table #10421

Closed
romainruaud opened this issue Aug 3, 2017 · 3 comments
Assignees
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@romainruaud
Copy link
Contributor

Preconditions

  1. Magento CE 2.1.7

Steps to reproduce

  1. Create a category (let's call it "Test").
  2. Assign products to this category.
  3. Save it
  4. Category/Product relations are properly figured in the catalog_category_product_index table.
  5. Delete this Category

Expected result

  1. Relations between products and this non-existing (deleted) category should be removed from catalog_category_product_index table

Actual result

  1. Relations are still shown in the table.

Eg, just after I have deleted the category with id "48" :

mysql> select * from catalog_category_product_index where category_id=48;
+-------------+------------+----------+-----------+----------+------------+
| category_id | product_id | position | is_parent | store_id | visibility |
+-------------+------------+----------+-----------+----------+------------+
|          48 |       2050 |        0 |         1 |        1 |          4 |
|          48 |       2050 |        0 |         1 |        2 |          4 |
|          48 |       2051 |        0 |         1 |        1 |          4 |
|          48 |       2051 |        0 |         1 |        2 |          4 |
|          48 |       2052 |        0 |         1 |        1 |          4 |
|          48 |       2052 |        0 |         1 |        2 |          4 |
+-------------+------------+----------+-----------+----------+------------+

Actually there are no foreign key between "category_id" and the catalog_category_entity table (or the sequence_category table if using EE).

Maybe adding the foreign key could be worth it. Or just ensure that the reindex() function of the category will properly reindex the products affected to this category before the deletion.

@magento-engcom-team magento-engcom-team added G1 Passed bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Sep 18, 2017
@magento-engcom-team
Copy link
Contributor

@romainruaud thank you for your bug report.
We've created internal ticket MAGETWO-75384 to track progress on the issue

@magento-engcom-team magento-engcom-team added the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Sep 19, 2017
@denysbabenko
Copy link
Contributor

I'm working on this issue.

@sidolov
Copy link
Contributor

sidolov commented Nov 23, 2017

Issue was fixed in 2.2-develop branch
Commit: e5f160a
Internal ticket: MAGETWO-82060

@sidolov sidolov closed this as completed Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

5 participants