Have an odd one here.
I was importing about 15 or so bundled products into Magento using Magmi when I encountered this error:
error 1:SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`nostalgi_mage2`.`mage_catalog_product_bundle_selection`, CONSTRAINT `FK_F2950E3208607C12E1E60C564D60F7D7` FOREIGN KEY (`option_id`) REFERENCES `mage_catalog_product_bundle_option` (`option_id) – INSERT INTO mage_catalog_product_bundle_selection (option_id, parent_product_id, product_id, position, is_default, selection_qty, selection_can_change_qty, selection_price_value, selection_price_type) VALUES(:option_id, :parent_product_id, :product_id, :position, :is_default, :selection_qty, :selection_can_change_qty, :selection_price_value, :selection_price_type)
error 2:SQLSTATE: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`nostalgi_mage2`.`mage_catalog_product_bundle_selection`, CONSTRAINT `FK_F2950E3208607C12E1E60C564D60F7D7` FOREIGN KEY (`option_id`) REFERENCES `mage_catalog_product_bundle_option` (`option_id) – ERROR ON RECORD #1
This repeats for each record I was trying to import.
I attempted to create these items initially, but they were imported as simple, rather than a bundled product.
I deleted them and then reimported them as bundled products.
Could that be the cause of the issue?
Potentially an indexing issue, or left-over data in the DB?
Not entirely sure, so I’m looking to you guys on some insight on this :-).
This does sound like a database issue. Have a look at your System>Index and see if any are showing an error. Try re-indexing if there are.
First: backup your database!
If no issues showing or still issues after re-indexing try these steps inside phpMyAdmin or equivalent:
See if any products are connected to a category which doesn’t exist:
See if any categories are connected to a product which doesn’t exist:
At this point double-check that you have a database backup and it works!
You can then get dangerous, if the first query returned a result:
If the second query returned a result:
Thanks for the prompt reply, I really appreciate it!
I both re-indexed the data and ran the SQL queries, but the data re-indexing didn’t work and the SQL results returned nothing.
Do you have anymore ideas?
Also, would it help to turn off the MYSQL foreign key check, or is that a bad idea?
Looking forward to your reply,
P.S: I am looking to start using Moogento’s products soon, so it’s reassuring knowing that the staff is responsive and friendly :-).
Hmm, at this point I usually hire someone who is more knowledgeable about this specific issue. I’ve spent days on it before and then found people that just sort it in an hour or less!
You could try one more thing – try reindexing from the command line (h/t @matt !). If you don’t have access to the command line, ask your host. That should return more detailed errors.
Good to hear you’re interested in our stuff, we try to make them as time-saving and useful as possible. (And try to respond in a working day to all queries)
You can do that here https://github.com/dweeves/magmi-git/issues
The Magmi code is maintained by @Sebastien BRACQUEMONT and always sharing such errors is suggested!
Why Should You Join UnderstandingE?
- Access to over 500 step-by-step video tutorials
- +20 video courses available
- Magento, M2E Pro, Magmi, eBay, Amazon & Design all covered
- Everything is in 100% Plain English
- Learn how to build your own multi-channel software for eBay & Amazon
- Access to the community forums, meet fellow business owners like yourself
Join Now with 2 Clicks
Join now for less that £1 per day you can gain access to over 400 step-by-step video tutorials & learn how to build your very own multi-channel software.
Most Users Ever Online: 1012
Currently Browsing this Page:
Jim @ Moogento: 688
Steve Froggatt: 514
Badeth - UE: 513
Paul Cartwright: 414
Administrators: Matthew Ogborne: 4565, Dave Furness: 4606