Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAffiliate example
public
function
hydrate
(
array
$data
)
{
$customer
=
new
Customer
(
)
;
$customer
->
setId
(
$data
[
'__customer_id'
]
)
;
$customer
->
setEncoder
(
$data
[
'__customer_encoder'
]
)
;
$customer
->
setEmail
(
$data
[
'__customer_email'
]
)
;
$customer
->
setActive
(
$data
[
'__customer_active'
]
)
;
$customer
->
setAccountMode
(
$data
[
'__customer_accountmode'
]
)
;
$customer
->
setConfirmationKey
(
$data
[
'__customer_confirmationkey'
]
)
;
$customer
->
setPaymentId
(
$data
[
'__customer_paymentID'
]
)
;
$customer
->
setValidation
(
$data
[
'__customer_validation'
]
)
;
$customer
->
setAffiliate
(
$data
[
'__customer_affiliate'
]
)
;
$customer
->
setPaymentPreset
(
$data
[
'__customer_paymentpreset'
]
)
;
$customer
->
setLanguageId
(
$data
[
'__customer_language'
]
)
;
$customer
->
setShopId
(
$data
[
'__customer_subshopID'
]
)
;
$customer
->
setReferer
(
$data
[
'__customer_referer'
]
)
;
$customer
->
setInternalComment
(
$data
[
'__customer_internalcomment'
]
)
;
$customer
->
setFailedLogins
(
$data
[
'__customer_failedlogins'
]
)
;
$customer
->
setDefaultBillingAddressId
(
$data
[
'__customer_default_billing_address_id'
]
)
;
$customer
->
setDefaultShippingAddressId
(
$data
[
'__customer_default_shipping_address_id'
]
)
;
$customer
->
setTitle
(
$data
[
'__customer_title'
]
)
;
$customer
->
setSalutation
(
$data
[
'__customer_salutation'
]
)
;
$customer
->
setFirstname
(
$data
[
'__customer_firstname'
]
)
;
$doubleOptinWithAccount
=
(
$accountMode
=== 0
)
&&
$config
->
get
(
'optinregister'
)
;
$doubleOptInAccountless
=
(
$accountMode
=== 1
)
&&
$config
->
get
(
'optinaccountless'
)
;
$doubleOptinRegister
=
$doubleOptinWithAccount
||
$doubleOptInAccountless
;
$shop
=
$context
->
getShop
(
)
;
$shop
->
addAttribute
(
'sendOptinMail',
new
Attribute
(
[
'sendOptinMail' =>
$doubleOptinRegister
,
]
)
)
;
$customer
->
setReferer
(
(string)
$session
->
offsetGet
(
'sReferer'
)
)
;
$customer
->
setValidation
(
(string)
(
$data
[
'register'
]
[
'personal'
]
[
'sValidation'
]
?? ''
)
)
;
$customer
->
setAffiliate
(
(int)
$session
->
offsetGet
(
'sPartner'
)
)
;
$customer
->
setPaymentId
(
(int)
$session
->
offsetGet
(
'sPaymentID'
)
)
;
$customer
->
setDoubleOptinRegister
(
$doubleOptinRegister
)
;
$customer
->
setDoubleOptinConfirmDate
(
null
)
;
/** @var Enlight_Event_EventManager $eventManager */
$eventManager
=
$this
->
get
(
'events'
)
;
$errors
=
[
'occurred' => false
]
;
$errors
=
$eventManager
->
filter
(
'Shopware_Modules_Admin_SaveRegister_BeforeRegister',
$errors
,
[
$customer
->
setLanguageSubShop
(
$subShop
)
;
if
(
$customer
->
getGroup
(
)
=== null
)
{
$customerGroup
=
$this
->modelManager->
find
(
Group::
class
,
$subShop
->
getCustomerGroup
(
)
->
getId
(
)
)
;
if
(
!
$customerGroup
instanceof Group
)
{
throw
new
ModelNotFoundException
(
Group::
class
,
$subShop
->
getCustomerGroup
(
)
->
getId
(
)
)
;
}
$customer
->
setGroup
(
$customerGroup
)
;
}
if
(
$customer
->
getAffiliate
(
)
)
{
$customer
->
setAffiliate
(
(int)
$this
->
getPartnerId
(
$customer
)
)
;
}
else
{
$customer
->
setAffiliate
(
0
)
;
}
if
(
!
$customer
->
getNumber
(
)
&&
$this
->config->
get
(
'shopwareManagedCustomerNumbers'
)
)
{
$customer
->
setNumber
(
(string)
$this
->numberIncrementer->
increment
(
'user'
)
)
;
}
$this
->validator->
validate
(
$customer
)
;
$this
->modelManager->
persist
(
$customer
)
;
$this
->modelManager->
flush
(
$customer
)
;