Magento : Create Customer programmatically

You can create a customer programmatically in Magento by given sample code:

<?php // create a customer in Magento

$websiteId = Mage::app()->getWebsite()->getId();

$store = Mage::app()->getStore(); $customer = Mage::getModel(‘customer/customer’);

$customer->website_id = $websiteId; $customer->setStore($store);

$customer->setFirstname(‘FirstName’);

$customer->setLastname(‘Lastname’);

$customer->email = “test@yourdomain.com”;

$customer->password_hash = md5(“testpassword”);

$customer->save();

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s