0

Each time i try to add Customizable Options to a product i got this error :

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`thailandnamage`.`catalog_product_option_title`, CONSTRAINT `CAT_PRD_OPT_TTL_OPT_ID_CAT_PRD_OPT_OPT_ID` FOREIGN KEY (`option_id`) REFERENCES `catalog_product_option` (`option_id`) ON DELETE CA), query was: INSERT INTO `catalog_product_option_title` (`option_id`, `store_id`, `title`) VALUES (?, ?, ?) 

Which says that magento cannot add orphan row to catalog_product_option_title, because the option_id don't exist into catalog_product_option but since it is new entry, why it can't add the row on that table first ? If the bug happen since the beginning i would understand, but why this bug start to happen ?

something wrong with the db ?

It start to occurs after i tried to add an article but the page didn't finish the task (504 error).

I have check the db, and it look ok... i even did a backup of the db from date before the bug occurs.

Does anyone know how was to check/fix ?

NB: When i try to import custom option from an other product i got this error (after saving the product):

No such entity. 

Thanks !

2 Answers 2

0

It wasn't coming from the db at all but from a patch i used...

https://github.com/magento/magento2/issues/8251

All these bug are a problem for magento. you need to patch the CMS to fix bug, but it creates other bugs... it never end. I am a bit disappointed by magento 2 for that.

0

I also had this problem. I solved it just by adding a couple of lines of code in

Magento\Catalog\Model\Product\Option\Repository.php
in the save method:

if ($option->getOptionId()) { ... } else $option->setOptionId(null); 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.