Magento Forum

   
Product Saving Error - Integrity constraint violation: 1452
 
salbertson
Jr. Member
 
Total Posts:  27
Joined:  2008-05-04
 

I am running version 1.0.19870.6 and had a solid install until importing a csv file to update prices. The csv has three columns; store, sku, and price. Now when adding products I get a “Product Saving Error” banner and stack trace output. Here is the output of my stack trace:

Cannot send headersheaders already sent in /usr/local/www/clients/magento/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.phpline 351
Trace
:
#0 /usr/local/www/clients/magento/lib/Zend/Controller/Response/Abstract.php(147): Zend_Controller_Response_Abstract->canSendHeaders(true)
#1 /usr/local/www/clients/magento/app/code/core/Mage/Adminhtml/Controller/Action.php(290): Zend_Controller_Response_Abstract->setRedirect('http://www.doll...')
#2 /usr/local/www/clients/magento/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php(361): Mage_Adminhtml_Controller_Action->_redirect('*/*/edit', Array)
#3 /usr/local/www/clients/magento/app/code/core/Mage/Core/Controller/Varien/Action.php(342): Mage_Adminhtml_Catalog_ProductController->saveAction()
#4 /usr/local/www/clients/magento/app/code/core/Mage/Core/Controller/Varien/Router/Admin.php(148): Mage_Core_Controller_Varien_Action->dispatch('save')
#5 /usr/local/www/clients/magento/app/code/core/Mage/Core/Controller/Varien/Front.php(146): Mage_Core_Controller_Varien_Router_Admin->match(Object(Mage_Core_Controller_Request_Http))
#6 /usr/local/www/clients/magento/app/Mage.php(427): Mage_Core_Controller_Varien_Front->dispatch()
#7 /usr/local/www/clients/magento/index.php(40): Mage::run()
#8 {main}

Here is the output the actual exception being thrown:

exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento_dollhouses/catalog_product_entity_varchar`, CONSTRAINT `FK_CATALOG_PRODUCT_ENTITY_VARCHAR_PRODUCT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity_orig` (`entity_i)' in /usr/local/www/clients/magento/lib/Zend/Db/Statement/Pdo.php:238

Any help is greatly appreciated, thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
acstudios
Jr. Member
 
Total Posts:  15
Joined:  2008-08-19
 

Any solution to this?  I’m having the same problem with v1.3.2.2

 
Magento Community Magento Community
Magento Community
Magento Community
 
Sirup
Jr. Member
 
Total Posts:  14
Joined:  2009-02-03
 

Hello,

I have the same problem on the 12.1
When i want to edit or add any product i have this error message :

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`Database/catalog_product_entity_varchar`, CONSTRAINT `FK_CATALOG_PRODUCT_ENTITY_VARCHAR_PRODUCT_ENTITY` FOREIGN KEY (`entity_id`) REFERENCES `___temp_dreamhost_restore_20090713_022606`)

I did not imported any products but i had some problems with magento while adding an extension, so i did a full re-install on a subfolder and used one backup of the database.
I have checked and all the database are InnoDB, so it doesn’t seems to be the problem.

Apparently it comes from some lost tables, the problem seems to be in the CATALOG_PRODUCT_ENTITY_VARCHAR table, but I don’t know how to search for the lost tables and I’m afraid to loose my products or categories.

BTW website is live… So if somebody could help me, I would REALLY appreciate it !

Thanks,

Steve

 
Magento Community Magento Community
Magento Community
Magento Community
 
Tom Coady
Member
 
Total Posts:  41
Joined:  2010-02-13
 

About that problem - looks like dreamhost is restoring DB from dump or so breaking foreign keys, they had non-needed prefixes in all dump, like:

WAS:
ALTER TABLE `catalogindex_aggregation`
ADD CONSTRAINT `FK_CATALOGINDEX_AGGREGATION_STORE` FOREIGN KEY (`store_id`) REFERENCES `___temp_dreamhost_restore_20100316_231038`.`core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;

NEEDS TO BE:
ALTER TABLE `catalogindex_aggregation`
ADD CONSTRAINT `FK_CATALOGINDEX_AGGREGATION_STORE` FOREIGN KEY (`store_id`) REFERENCES `core_store` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE;

Prefix is unwanted.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top