I'm stuck in a weird problem.

Everytime I try to create an account and add an address to that account programmatically I get an error called

A customer with the same email already exists in an associated website

This is my code for adding shipping and billing address to customer.

        //$customerId = $customer->getId();
        //Address info

         $customerAddress = $this->customerFactory->create()->setWebsiteId($websiteId)->loadByEmail($customer_email);
         $customerId = $customerAddress->getId();

         $address = $this->addressDataFactory->create();


Of course I'm adding differnt emails everytime I run this controller, but for some reason it keeps telling me that the email is already associated with another customer.

Please help


Once your forgot this line we got same error.

$customer = $this->accountManagement
                ->createAccount($customer, $password, $redirectUrl);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.