Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
customer_address.php
Go to the documentation of this file.
1 <?php
10 $customerAddress = $objectManager->create(\Magento\Customer\Model\Address::class);
12 $customerRegistry = $objectManager->get(\Magento\Customer\Model\CustomerRegistry::class);
13 $customerAddress->isObjectNew(true);
14 $customerAddress->setData(
15  [
16  'entity_id' => 1,
17  'attribute_set_id' => 2,
18  'telephone' => 3468676,
19  'postcode' => 75477,
20  'country_id' => 'US',
21  'city' => 'CityM',
22  'company' => 'CompanyName',
23  'street' => 'Green str, 67',
24  'lastname' => 'Smith',
25  'firstname' => 'John',
26  'parent_id' => 1,
27  'region_id' => 1,
28  ]
29 );
30 $customerAddress->save();
31 
33 $addressRepository = $objectManager->get(\Magento\Customer\Api\AddressRepositoryInterface::class);
35 $customerAddress->setCustomerId(1);
37 $customerRegistry->remove($customerAddress->getCustomerId());
39 $addressRegistry = $objectManager->get(\Magento\Customer\Model\AddressRegistry::class);
40 $addressRegistry->remove($customerAddress->getId());
$addressRepository
$objectManager
$addressRegistry
$customerRegistry
$customerAddress