Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 2
Integrity constraint violation: 1452 Cannot add or update a child row
 
qualle
Jr. Member
 
Avatar
Total Posts:  26
Joined:  2010-10-13
 

This Bug still exists in Magento Version 1.4.1.1.
Post #5 helped.
Thanks a lot!

 
Magento Community Magento Community
Magento Community
Magento Community
 
kornolio
Jr. Member
 
Total Posts:  13
Joined:  2009-04-01
 

Thanks a lot, mike222, you saved my life!! smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
yun
Jr. Member
 
Total Posts:  7
Joined:  2009-05-05
 
RickshawDriver - 31 January 2011 09:04 AM

Hi all,

I got the same issue so I look for a solution on this forum but despite a lots of solution posted on this forum, only Mike solution seems to works.

So I tried Mike solution but it did work for me maybe because I am not sure to understand properly what \” inserted the following code in the method _afterSave()\” mean.

In fact, because I can\’t find the terme \"method _afterSave()\” in my Quote.php file, I replace :

protected function _afterSave()
{
parent::_afterSave();

if (null !== $this->_addresses) {
$this->getAddressesCollection()->save();
}

if (null !== $this->_items) {
$this->getItemsCollection()->save();
}

if (null !== $this->_payments) {
$this->getPaymentsCollection()->save();
}
return $this;
}



TO :


protected function _afterSave()
{
parent::_afterSave();

if (null !== $this->_payments) {
// inserted code start
$this->getPaymentsCollection();
if ($this->getId()) {
foreach ($this->_payments as $payment) {
$payment->setQuote($this);
}
}
// inserted code end
$this->getPaymentsCollection()->save();
}
return $this;
}



Could you please tell me if I am doing the right modification ?

Thanks a lot

For anyone else stuck on finding the right place to insert the code - search for this line: if (null !== $this->_payments) and insert between the brackets at the location indicated.

I

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 2