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
customer_sample.php
Go to the documentation of this file.
1
<?php
6
use
Magento\Customer\Model\CustomerRegistry
;
7
9
$customer
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()
10
->create(\
Magento
\Customer\Model\Customer::class);
12
$customerRegistry
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->get(CustomerRegistry::class);
13
14
$customerData
= [
15
'group_id'
=> 1,
16
'website_id'
=> 1,
17
'store_id'
=> 1,
18
'firstname'
=>
'test firstname'
,
19
'lastname'
=>
'test lastname'
,
20
'email'
=>
'
[email protected]
'
,
21
'default_billing'
=> 1,
22
'password'
=>
'123123q'
,
23
'attribute_set_id'
=> 1,
24
];
25
$customer
->setData(
$customerData
);
26
$customer
->setId(1);
27
29
$addressOne
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
30
\
Magento
\Customer\Model\Address::class
31
);
32
$addressOneData
= [
33
'firstname'
=>
'test firstname'
,
34
'lastname'
=>
'test lastname'
,
35
'street'
=> [
'test street'
],
36
'city'
=>
'test city'
,
37
'region_id'
=> 10,
38
'country_id'
=>
'US'
,
39
'postcode'
=>
'01001'
,
40
'telephone'
=>
'+7000000001'
,
41
'entity_id'
=> 1,
42
];
43
$addressOne
->setData(
$addressOneData
);
44
$customer
->addAddress(
$addressOne
);
45
47
$addressTwo
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
48
\
Magento
\Customer\Model\Address::class
49
);
50
$addressTwoData
= [
51
'firstname'
=>
'test firstname'
,
52
'lastname'
=>
'test lastname'
,
53
'street'
=> [
'test street'
],
54
'city'
=>
'test city'
,
55
'region_id'
=> 10,
56
'country_id'
=>
'US'
,
57
'postcode'
=>
'01001'
,
58
'telephone'
=>
'+7000000001'
,
59
'entity_id'
=> 2,
60
];
61
$addressTwo
->setData(
$addressTwoData
);
62
$customer
->addAddress(
$addressTwo
);
63
65
$addressThree
=
\Magento\TestFramework\Helper\Bootstrap::getObjectManager
()->create(
66
\
Magento
\Customer\Model\Address::class
67
);
68
$addressThreeData
= [
69
'firstname'
=>
'removed firstname'
,
70
'lastname'
=>
'removed lastname'
,
71
'street'
=> [
'removed street'
],
72
'city'
=>
'removed city'
,
73
'region_id'
=> 10,
74
'country_id'
=>
'US'
,
75
'postcode'
=>
'01001'
,
76
'telephone'
=>
'+7000000001'
,
77
'entity_id'
=> 3,
78
];
79
$addressThree
->setData(
$addressThreeData
);
80
$customer
->addAddress(
$addressThree
);
81
82
$customer
->save();
83
$customerRegistry
->remove(
$customer
->getId());
$addressOne
$addressOne
Definition:
customer_sample.php:29
$customerData
$customerData
Definition:
customer_sample.php:14
$addressTwo
$addressTwo
Definition:
customer_sample.php:47
$addressThree
$addressThree
Definition:
customer_sample.php:65
$customerRegistry
$customerRegistry
Definition:
customer_sample.php:12
$customer
$customer
Definition:
customer_sample.php:9
$addressThreeData
$addressThreeData
Definition:
customer_sample.php:68
$addressTwoData
$addressTwoData
Definition:
customer_sample.php:50
Magento
$addressOneData
$addressOneData
Definition:
customer_sample.php:32
Magento\Customer\Model\CustomerRegistry
Definition:
CustomerRegistry.php:17
Magento\TestFramework\Helper\Bootstrap\getObjectManager
static getObjectManager()
Definition:
Bootstrap.php:125