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:
$siteId = Mage::app()->getWebsite()->getId(); $store = Mage::app()->getStore(); $customer_data = Mage::getModel("customer/customer"); $customer_data ->setWebsiteId($siteId) ->setStore($store) ->setGroupId(2) ->setPrefix('Sir') ->setFirstname('EWA') ->setMiddleName('2') ->setLastname('Developer') ->setSuffix('II') ->setEmail('expertwebadvisor@gmail.com') ->setPassword('amdin@123'); try{ $customer_data->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); }
By using the above code you can successfully create the user and if you want to assign the address to this customer just follow the step given below:
$address_data = Mage::getModel("customer/address"); $address_data ->setCustomerId($customer_data->getId()) ->setFirstname($customer_data->getFirstname()) ->setMiddleName($customer_data->getMiddlename()) ->setLastname($customer_data->getLastname()) //->setRegionId('1') //state/province, only needed country is USA ->setPostcode('90001') ->setCity('Alaska') ->setTelephone('032845785') ->setFax('032845785') ->setCompany('EWA') ->setStreet('Chakresia') ->setIsDefaultBilling('1') ->setIsDefaultShipping('1') ->setSaveInAddressBook('1'); try{ $address_data->save(); } catch (Exception $e) { Zend_Debug::dump($e->getMessage()); }
Now the customer with the address, so now this customer is ready for the order.
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.