Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
address_list.php
Go to the documentation of this file.
1 <?php
8  [
9  'telephone' => 3234676,
10  'postcode' => 47676,
11  'country_id' => 'US',
12  'city' => 'CityX',
13  'street' => ['Black str, 48'],
14  'lastname' => 'Smith',
15  'firstname' => 'John',
16  'address_type' => 'shipping',
17  'email' => '[email protected]',
18  'region_id' => 1,
19  ],
20  [
21  'telephone' => 3234676,
22  'postcode' => '47676',
23  'country_id' => 'US',
24  'city' => 'CityX',
25  'street' => ['Black str, 48'],
26  'lastname' => 'Smith',
27  'firstname' => 'John',
28  'address_type' => 'billing',
29  'email' => '[email protected]',
30  'region_id' => 1,
31  ],
32  [
33  'telephone' => 123123,
34  'postcode' => 'ZX0789',
35  'country_id' => 'US',
36  'city' => 'Ena4ka',
37  'street' => ['Black', 'White'],
38  'lastname' => 'Doe',
39  'firstname' => 'John',
40  'address_type' => 'billing',
41  'email' => '[email protected]',
42  'region_id' => 2,
43  ],
44  [
45  'telephone' => 123123,
46  'postcode' => 'ZX0789A',
47  'country_id' => 'US',
48  'city' => 'Ena4ka',
49  'street' => ['Black', 'White'],
50  'lastname' => 'Doe',
51  'firstname' => 'John',
52  'address_type' => 'shipping',
53  'email' => '[email protected]',
54  'region_id' => 1,
55  ]
56 ];
57 
59 foreach ($addresses as $addressData) {
62  \Magento\Sales\Model\Order\Address::class
63  );
64  $address
65  ->setData($addressData)
66  ->save();
67 }
$addresses
Definition: address_list.php:7
$address
Definition: customer.php:38
$addressData
Definition: order.php:19