add random customers to Magento database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//PHP array containing forenames. | |
$names = array( | |
'Joao', | |
'Alberto', | |
'Jose', | |
'Raimundo', | |
'Carlos', | |
'Fabio', | |
'David', | |
'Mell', | |
); | |
//PHP array containing surnames. | |
$surnames = array( | |
'Vilas', | |
'Martins', | |
'Angeluci', | |
'Johnson', | |
'Tremblay', | |
'Peltier', | |
'Cunningham', | |
'Simpson', | |
'Mercado', | |
'Sellers' | |
); | |
$websiteId = Mage::app()->getWebsite()->getId(); | |
$store = Mage::app()->getStore(); | |
for($i=0; $i<30; $i++) { | |
//Generate a random forename. | |
$random_name = $names[mt_rand(0, sizeof($names) - 1)]; | |
//Generate a random surname. | |
$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)]; | |
echo "Adding user: "; | |
echo $random_name . ' ' . $random_surname; | |
echo "<br>"; | |
$customer = Mage::getModel("customer/customer"); | |
$customer ->setWebsiteId($websiteId) | |
->setStore($store) | |
->setFirstname($random_name) | |
->setLastname($random_surname) | |
->setEmail('user'.$i.'@rededots.com.br') | |
->setPassword('somepassword'); | |
try{ | |
$customer->save(); | |
} | |
catch (Exception $e) { | |
Zend_Debug::dump($e->getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment