Skip to main content
added 39 characters in body
Source Link
Fabian Blechschmidt
  • 35.4k
  • 8
  • 75
  • 182

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId())
    ->setFirstname($customer->getFirstname())
    ->setMiddleName($customer->getMiddlename())
    ->setLastname($customer->getLastname())
    ->setCountryId('US')
    //->setRegionId('1') //state/province, only needed if the country is USA
    ->setPostcode('90210')
    ->setCity('Beverly Hills')
    ->setTelephone('123')
    ->setFax('123')
    ->setCompany('Company')
    ->setStreet('Street')
    ->setIsDefaultBilling('1')
    ->setIsDefaultShipping('1')
    ->setSaveInAddressBook('1');

try{
    $address->save();
}
catch (Exception $e) {
    Zend_Debug::dump($e->getMessage());
}

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`customer_address_entity`, CONSTRAINT `FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`parent_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228
Stack trace:
#0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array)
#1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) 
#2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) 
#3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) 
#4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId())
    ->setFirstname($customer->getFirstname())
    ->setMiddleName($customer->getMiddlename())
    ->setLastname($customer->getLastname())
    ->setCountryId('US')
    //->setRegionId('1') //state/province, only needed if the country is USA
    ->setPostcode('90210')
    ->setCity('Beverly Hills')
    ->setTelephone('123')
    ->setFax('123')
    ->setCompany('Company')
    ->setStreet('Street')
    ->setIsDefaultBilling('1')
    ->setIsDefaultShipping('1')
    ->setSaveInAddressBook('1');

try{
    $address->save();
}
catch (Exception $e) {
    Zend_Debug::dump($e->getMessage());
}

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId())
    ->setFirstname($customer->getFirstname())
    ->setMiddleName($customer->getMiddlename())
    ->setLastname($customer->getLastname())
    ->setCountryId('US')
    //->setRegionId('1') //state/province, only needed if the country is USA
    ->setPostcode('90210')
    ->setCity('Beverly Hills')
    ->setTelephone('123')
    ->setFax('123')
    ->setCompany('Company')
    ->setStreet('Street')
    ->setIsDefaultBilling('1')
    ->setIsDefaultShipping('1')
    ->setSaveInAddressBook('1');

try{
    $address->save();
}
catch (Exception $e) {
    Zend_Debug::dump($e->getMessage());
}

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`magento`.`customer_address_entity`, CONSTRAINT `FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID` FOREIGN KEY (`parent_id`) REFERENCES `customer_entity` (`entity_id`) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228
Stack trace:
#0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array)
#1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) 
#2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) 
#3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) 
#4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

added 96 characters in body; edited tags
Source Link
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address"); $address->setCustomerId($customer->getId()) ->setFirstname($customer->getFirstname()) ->setMiddleName($customer->getMiddlename()) ->setLastname($customer->getLastname()) ->setCountryId('US') //->setRegionId('1') //state/province, only needed if the country is USA ->setPostcode('90210') ->setCity('Beverly Hills') ->setTelephone('123') ->setFax('123') ->setCompany('Company') ->setStreet('Street') ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1');

try{ $address->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); }

$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId())
    ->setFirstname($customer->getFirstname())
    ->setMiddleName($customer->getMiddlename())
    ->setLastname($customer->getLastname())
    ->setCountryId('US')
    //->setRegionId('1') //state/province, only needed if the country is USA
    ->setPostcode('90210')
    ->setCity('Beverly Hills')
    ->setTelephone('123')
    ->setFax('123')
    ->setCompany('Company')
    ->setStreet('Street')
    ->setIsDefaultBilling('1')
    ->setIsDefaultShipping('1')
    ->setSaveInAddressBook('1');

try{
    $address->save();
}
catch (Exception $e) {
    Zend_Debug::dump($e->getMessage());
}

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address"); $address->setCustomerId($customer->getId()) ->setFirstname($customer->getFirstname()) ->setMiddleName($customer->getMiddlename()) ->setLastname($customer->getLastname()) ->setCountryId('US') //->setRegionId('1') //state/province, only needed if the country is USA ->setPostcode('90210') ->setCity('Beverly Hills') ->setTelephone('123') ->setFax('123') ->setCompany('Company') ->setStreet('Street') ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1');

try{ $address->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); }

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address");
$address->setCustomerId($customer->getId())
    ->setFirstname($customer->getFirstname())
    ->setMiddleName($customer->getMiddlename())
    ->setLastname($customer->getLastname())
    ->setCountryId('US')
    //->setRegionId('1') //state/province, only needed if the country is USA
    ->setPostcode('90210')
    ->setCity('Beverly Hills')
    ->setTelephone('123')
    ->setFax('123')
    ->setCompany('Company')
    ->setStreet('Street')
    ->setIsDefaultBilling('1')
    ->setIsDefaultShipping('1')
    ->setSaveInAddressBook('1');

try{
    $address->save();
}
catch (Exception $e) {
    Zend_Debug::dump($e->getMessage());
}

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks

Source Link
neha
  • 11
  • 2

into magento, I create new customer form from mobile and how to insert its value into customer table?

I want to insert some information of customer into all customer tables from outside form but I am not able to insert it and I have also used following code :

$address = Mage::getModel("customer/address"); $address->setCustomerId($customer->getId()) ->setFirstname($customer->getFirstname()) ->setMiddleName($customer->getMiddlename()) ->setLastname($customer->getLastname()) ->setCountryId('US') //->setRegionId('1') //state/province, only needed if the country is USA ->setPostcode('90210') ->setCity('Beverly Hills') ->setTelephone('123') ->setFax('123') ->setCompany('Company') ->setStreet('Street') ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1');

try{ $address->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); }

But I am getting some error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (magento.customer_address_entity, CONSTRAINT FK_CUSTOMER_ADDRESS_ENTITY_PARENT_ID_CUSTOMER_ENTITY_ENTITY_ID FOREIGN KEY (parent_id) REFERENCES customer_entity (entity_id) ON DELETE )' in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php:228 Stack trace: #0 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php(228): PDOStatement->execute(Array) #1 C:\wamp\www\magento\mmm\magento\lib\Varien\Db\Statement\Pdo\Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) #2 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) #3 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array) #4 C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `cu...', Array) in C:\wamp\www\magento\mmm\magento\lib\Zend\Db\Statement\Pdo.php on line 234

Please help me and suggest me how to solve it so that I can insert some information of customer into database from outside form. Thanks