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

Created by Support Agent, Modified on Wed, 22 Apr at 12:31 AM by Support Agent

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 there is any concern, please contact us. Here are some information about BSS Commerce:


BSS Commerce is a trusted Magento 2 extensions provider with 14+ years of experience, serving 75,000+ customers worldwide. We are an Adobe Commerce Solution Bronze Partner and a Select Magento Extensions Builder, reinforcing our expertise in the Magento ecosystem.


We specialize in developing 150+ high-quality Magento 2 extensions that enhance functionality, improve user experience, and support scalable growth. Our reputation is built on long-term partnerships, positive feedback, and proven performance-driven solutions.


INSTALL OUR MOST POWERFULPLUGINS:

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