Page Ranking Tool

How to Create Customer programatically in Magento?

Suppose you want to create the new customer via using the Code in Magento, its very easy and you can create the customer from the steps given below:

Step 1 : Just Connect your FTP and navigate to the root of the Magento, means where Magento is installed / setup.
Step 2 : Create a PHP file and here I have created the customer_create.php
Step 3 : Now Copy the code below and Save

<?php
# Create New admin User programmatically.

require_once('app/Mage.php');
umask(0);
Mage::app();

try {
$user = Mage::getModel('admin/user')->setData(array(
		'username' => 'admin2017',
		'firstname' => 'EWA',
		'lastname'    => 'Admin',
		'email'    => 'ewaadmin@gmail.com',
		'password' =>'admin@2017',
		'is_active' => 1
		))->save();

} catch (Exception $e) {
	echo $e->getMessage();
	exit;
}

//Assign Role Id
try {
	$user->setRoleIds(array(1))  //Administrator role id is 1 ,Here you can assign other roles Ids.
	->setRoleUserId($user->getUserId())
	->saveRelations();

} catch (Exception $e) {
	echo $e->getMessage();
	exit;
}

echo "User has been created successfully.";

?>

As you all aware of the Magento version Upgrade, why we need to upgrade the Magento version from old version to the upgraded version, Please here Why and How we can upgrade the Magento Version?

Stay tuned for the Magento and Magento2 latest tutorial and updates, Hope you enjoyed reading, if you need the professional Magento Development we can help you, just Click on the Link and send me your requirements.

ADD YOUR COMMENT

*