Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
updateStockAndSales example
if
(
$event
->
getContext
(
)
->
getVersionId
(
)
!== Defaults::LIVE_VERSION
)
{
return
;
}
if
(
$event
->
getEntityName
(
)
!== 'order'
)
{
return
;
}
if
(
$event
->
getToPlace
(
)
->
getTechnicalName
(
)
=== OrderStates::STATE_COMPLETED
)
{
$products
=
$this
->
getProductsOfOrder
(
$event
->
getEntityId
(
)
,
$event
->
getContext
(
)
)
;
$this
->
updateStockAndSales
(
$products
, -1
)
;
return
;
}
if
(
$event
->
getFromPlace
(
)
->
getTechnicalName
(
)
=== OrderStates::STATE_COMPLETED
)
{
$products
=
$this
->
getProductsOfOrder
(
$event
->
getEntityId
(
)
,
$event
->
getContext
(
)
)
;
$this
->
updateStockAndSales
(
$products
, +1
)
;
return
;
}