Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getNewValue example
'orderID' =>
$order
->
getId
(
)
,
]
;
if
(
$this
->
hasIdentity
(
)
)
{
$user
=
$eventArgs
->
getEntityManager
(
)
->
find
(
\Shopware\Models\User\User::
class
,
Shopware
(
)
->
Container
(
)
->
get
(
'auth'
)
->
getIdentity
(
)
->id
)
;
$historyData
[
'userID'
]
=
$user
->
getId
(
)
;
}
// Order status changed?
if
(
$eventArgs
->
hasChangedField
(
'orderStatus'
)
)
{
$historyData
[
'previous_order_status_id'
]
=
$eventArgs
->
getOldValue
(
'orderStatus'
)
->
getId
(
)
;
$historyData
[
'order_status_id'
]
=
$eventArgs
->
getNewValue
(
'orderStatus'
)
->
getId
(
)
;
}
else
{
$historyData
[
'previous_order_status_id'
]
=
$order
->
getOrderStatus
(
)
->
getId
(
)
;
$historyData
[
'order_status_id'
]
=
$order
->
getOrderStatus
(
)
->
getId
(
)
;
}
// Payment status changed?
if
(
$eventArgs
->
hasChangedField
(
'paymentStatus'
)
)
{
$historyData
[
'previous_payment_status_id'
]
=
$eventArgs
->
getOldValue
(
'paymentStatus'
)
->
getId
(
)
;
$historyData
[
'payment_status_id'
]
=
$eventArgs
->
getNewValue
(
'paymentStatus'
)
->
getId
(
)
;
}
else
{
$historyData
[
'previous_payment_status_id'
]
=
$order
->
getPaymentStatus
(
)
->
getId
(
)
;