Hello Developers,
When I was started working in magento. i found so many problem in custom development in
magento. i tried so many times for google those things. When you are working with customer module
then you need to know everything about magento customer collection.
some time you want to add new customer programmatically on magento store. most of developer
add customers on store using programmically becasue it is so fast and easy for them.
Your can try this code to create new customer in magento store.
$website_Id = Mage::app()->getWebsite()->getId();
$store_id = Mage::app()->getStore();
$new_customer = Mage::getModel("customer/customer");
$new_customer ->setWebsiteId($websiteId)
->setStore($store_id)
->setFirstname('star')
->setLastname('Gennius')
->setEmail('[email protected]')
->setTelephone('0987656532')
->setStreet('New Delhi')
->setCountry('India');
try{
$new_customer->save();
}
catch (Exception $e) {
Zend_Debug::dump($e->getMessage());
}
If you want to setup auto password then just use this code instead of password in abobe
code.
$customer->setPassword($customer->generatePassword($pwd_length));
$website_Id = Mage::app()->getWebsite()->getId();
$store_id = Mage::app()->getStore();
$new_customer = Mage::getModel("customer/customer");
$new_customer ->setWebsiteId($websiteId)
->setStore($store_id)
->setFirstname('star')
->setLastname('Gennius')
->setEmail('[email protected]')
->setTelephone('0987656532')
->setStreet('New Delhi')
->setCountry('India')
->setConfirmation(0)
->sendNewAccountEmail(0);
try{
$new_customer->save();
}
catch (Exception $e) {
Zend_Debug::dump($e->getMessage());
}
Thank you for reading my tutorial. comments here if you got any error. i will help you ASAP.
For more information on programmatically adding new, feel free to reach out to our team.
Is Your Magento Store Secure?
Vulnerabilities like CosmicSting and SessionReaper are actively exploited. Scan your website in seconds to detect malware, exposed endpoints, and missing patches.
Run Free Security Scan on MageArgus →
Fact-Checked & Verified by W3ctrl
This content has been written and reviewed by Adobe-Certified Technical Experts with over 16 years of experience in Enterprise Architecture.
