Create customer magento 2 programmatically

           
            $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
            $url = \Magento\Framework\App\ObjectManager::getInstance();
            $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');
            $customerFactory = $objectManager->get('\Magento\Customer\Model\CustomerFactory');
            $customer = $customerFactory->create();
            $customer->setWebsiteId(1);
            $customer->setEmail("codesbug@mail.com");
            $customer->setFirstname("codes");
            $customer->setLastname("bug");
            $customer->setPassword("user@123");
            $customer->setGroupId(4);
            $customer->save();

            echo 'Create customer successfully'.$customer->getId();

Comments