0

I'm trying to add simple products to a bundle in Magento, but I'm getting an SQL error whenever I try. The specific error I'm getting is

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails ('magento'.'catalog_product_relation', CONSTRAINT 'FK_CAT_PRD_RELATION_CHILD_ID_CAT_PRD_ENTT_ENTT_ID' FOREIGN KEY ('child_id') REFERENCES 'catalog_product_entity' ('entity_id') ON DELETE CASCAD), query was: INSERT INTO 'catalog_product_relation' ('parent_id','child_id') VALUES (?, ?)

So essentially, when trying to add a new row to catalog_product_relation, for each product I try to add, rather than the bundle and simple product ID's it's using ?,?.

This is quite a large bundle with over 250 simple products spread across 10 categories, I've checked the catalog_product_relation table and there's no unexpected rows, and I've made sure all products are available in this store/website and are enabled, is anyone able to shed any light on why it's passing through these blank values?


EDIT: It seems that after having successfully added two or three simple products without getting the SQL error, 20 products which were previously saved without issue have disappeared from the bundle, their empty categories are still there however

0

As usual, I spent days trying to solve this, and then found a solution minutes after giving in and asking for help online. Here's the answer, in case it can help anyone else in the future.

I realised the products that had been 'cut off' after saving were all at the end of the form, so it was actually those that weren't returning values for the catalog_product_relation table. The culprit was my php settings, namely max_input_vars. I added a few zeroes to the end of the value and now the bundle is saving without issue.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.