Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
customers.php
Go to the documentation of this file.
1 <?php
8 
10 $repository = $objectManager->create(\Magento\Customer\Api\CustomerRepositoryInterface::class);
11 $customer = $objectManager->create(\Magento\Customer\Model\Customer::class);
12 $customerRegistry = $objectManager->get(CustomerRegistry::class);
13 $customer->setWebsiteId(1)
14  ->setId(1)
15  ->setEmail('[email protected]')
16  ->setPassword('password')
17  ->setGroupId(1)
18  ->setStoreId(1)
19  ->setIsActive(1)
20  ->setFirstname('John')
21  ->setLastname('Smith')
22  ->setDefaultBilling(1)
23  ->setDefaultShipping(1);
24 $customer->isObjectNew(true);
25 $customer->save();
26 
27 $customer->setWebsiteId(1)
28  ->setId(2)
29  ->setEmail('[email protected]')
30  ->setPassword('password')
31  ->setGroupId(1)
32  ->setStoreId(1)
33  ->setIsActive(1)
34  ->setFirstname('Jane')
35  ->setLastname('Smith')
36  ->setDefaultBilling(1)
37  ->setDefaultShipping(1);
38 $customer->isObjectNew(true);
39 $customer->save();
40 
41 $customerRegistry->remove($customer->getId());
$customer
Definition: customers.php:11
$repository
Definition: customers.php:10
$customerRegistry
Definition: customers.php:12
$objectManager
Definition: customers.php:9