Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
magento2-base
dev
tests
integration
testsuite
Magento
Customer
_files
import_export
customers_for_address_import.php
Go to the documentation of this file.
1
<?php
6
//Create customer
8
$customer
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
9
\
Magento
\Customer\Model\Customer::class
10
);
11
$customer
->setWebsiteId(
12
0
13
)->setEntityId(
14
1
15
)->setEntityTypeId(
16
1
17
)->setAttributeSetId(
18
0
19
)->setEmail(
20
'
[email protected]
'
21
)->setPassword(
22
'password'
23
)->setGroupId(
24
0
25
)->setStoreId(
26
0
27
)->setIsActive(
28
1
29
)->setFirstname(
30
'Betsy'
31
)->setLastname(
32
'Parker'
33
)->setGender(
34
2
35
);
36
$customer
->isObjectNew(
true
);
37
$customer
->save();
38
39
// Create and set addresses
40
$addressFirst
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
41
\
Magento
\Customer\Model\Address::class
42
);
43
$addressFirst
->addData(
44
[
45
'entity_id'
=> 1,
46
'firstname'
=>
'Betsy'
,
47
'lastname'
=>
'Parker'
,
48
'street'
=>
'1079 Rocky Road'
,
49
'city'
=>
'Philadelphia'
,
50
'country_id'
=>
'US'
,
51
'region_id'
=>
'51'
,
52
'postcode'
=>
'19107'
,
53
'telephone'
=>
'215-629-9720'
,
54
]
55
);
56
$addressFirst
->isObjectNew(
true
);
57
$customer
->addAddress(
$addressFirst
);
58
$customer
->setDefaultBilling(
$addressFirst
->getId());
59
60
$addressSecond
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
61
\
Magento
\Customer\Model\Address::class
62
);
63
$addressSecond
->addData(
64
[
65
'entity_id'
=> 2,
66
'firstname'
=>
'Anthony'
,
67
'lastname'
=>
'Nealy'
,
68
'street'
=>
'3176 Cambridge Court'
,
69
'city'
=>
'Fayetteville'
,
70
'country_id'
=>
'US'
,
71
'region_id'
=>
'5'
,
72
'postcode'
=>
'72701'
,
73
'telephone'
=>
'479-899-9849'
,
74
]
75
);
76
$addressSecond
->isObjectNew(
true
);
77
$customer
->addAddress(
$addressSecond
);
78
$customer
->setDefaultShipping(
$addressSecond
->getId());
79
$customer
->save();
$addressFirst
$addressFirst
Definition:
customers_for_address_import.php:40
$addressSecond
$addressSecond
Definition:
customers_for_address_import.php:60
Magento
$customer
$customer
Definition:
customers_for_address_import.php:8
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125