[v1.0.1] Fix issue Cannot add or update a child row: a foreign key constraint fails

Created by Rosa Truong, Modified on Tue, 18 May, 2021 at 3:46 PM by Rosa Truong

Issue:


We have installed module version 1.0.1 on Magento 2.4. When answering the question and tick Notify customer, the customers don't receive any notification per email.


See error from var/log/system.log

[2021-04-22 19:13:42] main.CRITICAL: Bss Product Question has few bugs.SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`uitlaatstore_preinstalled_magento`.`bss_pq_comment_product_link`, CONSTRAINT `BSS_PQ_COMMENT_PRODUCT_LINK_COMMENT_ID_BSS_PQ_COMMENTS_ID` FOREIGN KEY (`comment_id`) REFERENCES `bss_pq_comments), query was: INSERT INTO `bss_pq_comment_product_link` () VALUES () [] []


Solution:


The issue happens due to the module's bug so we would like to give a quick solution.

To solve it, please add these files on the site

app/code/Bss/ProductQuestionsFixBug/Override/Model/CommentProductLinkRepository.php

app/code/Bss/ProductQuestionsFixBug/etc/di.xml

app/code/Bss/ProductQuestionsFixBug/etc/module.xml

app/code/Bss/ProductQuestionsFixBug/registration.php


Please check and apply the fixed attachment to the site and flush the cache.


If you need any further assistance, please feel free to contact us.

We're more than happy to support you.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article