Check the following root script to create customer programmatically:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
use Magento\Framework\App\Bootstrap; require 'app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('\Magento\Framework\App\State'); $state->setAreaCode('frontend'); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $storeId = $storeManager->getStore()->getId(); $websiteId = $storeManager->getStore($storeId)->getWebsiteId(); try { $customer = $objectManager->get('\Magento\Customer\Api\Data\CustomerInterfaceFactory')->create(); $customer->setWebsiteId($websiteId); $email = 'ex00@example.com'; $customer->setEmail($email); $customer->setFirstname("example first"); $customer->setLastname("example last"); $hashedPassword = $objectManager->get('\Magento\Framework\Encryption\EncryptorInterface')->getHash('MyNewPass', true); $objectManager->get('\Magento\Customer\Api\CustomerRepositoryInterface')->save($customer, $hashedPassword); $customer = $objectManager->get('\Magento\Customer\Model\CustomerFactory')->create(); $customer->setWebsiteId($websiteId)->loadByEmail($email); } catch (Exception $e) { echo $e->getMessage(); } |
Run the above script code in a loop and create multiple customers at a time, by changing the email ID every time.
That’s it!
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-6284576708023095342069/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...