Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
firstName example
$netCustomerGroupId
=
$this
->
createNetCustomerGroup
(
$context
->
getContext
(
)
)
;
$customerGroups
=
[
TestDefaults::FALLBACK_CUSTOMER_GROUP,
$netCustomerGroupId
]
;
$tags
=
$this
->
getIds
(
'tag'
)
;
$salesChannelIds
=
$this
->connection->
fetchFirstColumn
(
'SELECT LOWER(HEX(id)) FROM sales_channel'
)
;
$countries
=
$this
->connection->
fetchFirstColumn
(
'SELECT id FROM country WHERE active = 1'
)
;
$payload
=
[
]
;
for
(
$i
= 0;
$i
<
$numberOfItems
; ++
$i
)
{
$id
= Uuid::
randomHex
(
)
;
$firstName
=
$context
->
getFaker
(
)
->
firstName
(
)
;
$lastName
=
$context
->
getFaker
(
)
->
format
(
'lastName'
)
;
$salutationId
= Uuid::
fromBytesToHex
(
$this
->
getRandomSalutationId
(
)
)
;
$title
=
$this
->
getRandomTitle
(
)
;
$addresses
=
[
]
;
$aCount
=
random_int
(
2, 5
)
;
for
(
$x
= 1;
$x
<
$aCount
; ++
$x
)
{
$addresses
[
]
=
[
'id' => Uuid::
randomHex
(
)
,
'countryId' => Uuid::
fromBytesToHex
(
$context
->
getFaker
(
)
->
randomElement
(
$countries
)
)
,
public
function
generate
(
int
$numberOfItems
, DemodataContext
$context
, array
$options
=
[
]
)
: void
{
$writeContext
= WriteContext::
createFromContext
(
$context
->
getContext
(
)
)
;
$context
->
getConsole
(
)
->
progressStart
(
$numberOfItems
)
;
$payload
=
[
]
;
for
(
$i
= 0;
$i
<
$numberOfItems
; ++
$i
)
{
$id
= Uuid::
randomHex
(
)
;
$firstName
=
$context
->
getFaker
(
)
->
firstName
(
)
;
$lastName
=
$context
->
getFaker
(
)
->
format
(
'lastName'
)
;
$title
=
$this
->
getRandomTitle
(
)
;
$user
=
[
'id' =>
$id
,
'title' =>
$title
,
'firstName' =>
$firstName
,
'lastName' =>
$lastName
,
'username' =>
$context
->
getFaker
(
)
->
format
(
'userName'
)
,
'email' =>
$id
.
$context
->
getFaker
(
)
->
format
(
'safeEmail'
)
,
'password' => 'shopware',
$this
->ids =
new
IdsCollection
(
)
;
$this
->
resetHistory
(
)
;
}
protected
function
createCustomer
(
)
: string
{
$customerId
=
$this
->ids->
get
(
'customer'
)
;
$addressId
=
$this
->ids->
get
(
'address'
)
;
$customer
=
(
new
CustomerBuilder
(
$this
->ids, '1337'
)
)
->
firstName
(
'Max'
)
->
lastName
(
'Mustermann'
)
->
add
(
'id',
$this
->ids->
get
(
'customer'
)
)
->
add
(
'email', Uuid::
randomHex
(
)
. '@example.com'
)
->
add
(
'salesChannelId', TestDefaults::SALES_CHANNEL
)
->
add
(
'password', 'shopware'
)
->
add
(
'defaultPaymentMethodId',
$this
->
getValidPaymentMethodId
(
)
)
->
defaultShippingAddress
(
'address'
)
->
defaultBillingAddress
(
'address',
[
'id' =>
$addressId
,
'customerId' =>
$customerId
,
'countryId' =>
$this
->
getValidCountryId
(
)
,