This phrase gave me nightmares for days as I was building the new BeltBuckle.com website. We installed a ton of extensions to automate the website, and somewhere along the line some database tables got corrupted, so I had to start a what seemed like an endless game of cat and mouse chasing down what was really wrong with the site. I’ve compiled a list of everything I tried along the way to fix the issue:
- Make sure the var/locks folder is writable. Test out full permissions (chmod 777).
- Delete all of the .locks files from the var/locks folder.
- Backup your database, then run this query in phpmyadmin: DELETE FROM catalog_category_product_index;
- Try the magento cleanup tool
- Try the magento database repair tool
- Backup your database and run this query in phpmyadmin:
DELETE cpop.* FROM catalog_product_option_price AS cpop
INNER JOIN catalog_product_option AS cpo
ON cpo.option_id = cpop.option_id
WHERE
cpo.type = ‘checkbox’ OR
cpo.type = ‘radio’ OR
cpo.type = ‘drop_down’;DELETE cpotp.* FROM catalog_product_option_type_price AS cpotp
INNER JOIN catalog_product_option_type_value AS cpotv
ON cpotv.option_type_id = cpotp.option_type_id
INNER JOIN catalog_product_option AS cpo
ON cpotv.option_id = cpo.option_id
WHERE
cpo.type <> ‘checkbox’ AND
cpo.type <> ‘radio’ AND
cpo.type <> ‘drop_down’;
After running all of these options and still not having any luck in the admin, I decided to try and reindex by command line. Just SSH into your site, and run this command:
Magento will then start to run the reindex process, updating the command line as it progresses. When it hits the error mark, it will show you what the actual error is. In my case, this is what I got:
Product Flat Data index process unknown error:
exception ‘PDOException’ with message ‘SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`alleight_bbcom/#sql-6d5d_2cb103`, CONSTRAINT `FK_CAT_PRD_FLAT_1_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE ON )’ in /home/alleight/public_html/bbcom/lib/Zend/Db/Statement/Pdo.php:228
In the error, you can see that there’s a problem with the catalog product flat data. We simply truncated the table catalog_flat_product_1, and voila. Reindex successful.


I hate you (and secretly love you) for introducing me to beltbuckle.com – I just went and spent $100 there on some cool tin. Thanks and
Oh, and cheers for the Magento solve…
Awesome! Thanks for being a customer!
Thanks for sharing the complete process. I solved my problem using SSH
php /path/to/magento/shell/indexer.php reindexall
It showed some error :
Product Prices index process unknown error:
So i truncated catalog_product_entity_group_price table and it worked.
Thanks for Share.
You’re welcome! Glad I could help.
I am at my wits end, I have followed your steps.
Was stuck with the database repair tool. Do I need to install a fresh copy of magento in database3 step so I have a clean version of same version of magento for it to compare.
If so I did this and then it turned my repaired database into the default magento template instead of my template. Think Im going just a little bit insane!
Magento has a tendency to make you go a little insane.
No, you don’t have to install a fresh copy in step 3. I mentioned the backup since you’re editing the database directly so it’s always good to do a backup in case something funky happens when you’re running that query.
So if you installed a fresh copy of Magento, did you upload your theme again? You might just have to upload your theme again and change the design in the admin.
I have your problem … but in catalog_product_flat_3
should I delete all the entries from here????
I won’t delete my products??
t
You can truncate catalog_product_flat tables without deleting your entire product catalog. However, I highly recommend doing a backup of your database before doing any direct database edits.