Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setSerialnumber example
$newSerials
= 0;
foreach
(
$serials
as
$serialnumber
)
{
$serialnumber
=
trim
(
$serialnumber
)
;
$serial
=
$this
->
get
(
'models'
)
->
getRepository
(
EsdSerial::
class
)
->
findOneBy
(
[
'serialnumber' =>
$serialnumber
]
)
;
if
(
$serial
)
{
continue
;
}
$serial
=
new
EsdSerial
(
)
;
$serial
->
setSerialnumber
(
$serialnumber
)
;
$serial
->
setEsd
(
$esd
)
;
$this
->
getManager
(
)
->
persist
(
$serial
)
;
++
$newSerials
;
}
$this
->
getManager
(
)
->
flush
(
)
;
// Update stock
$freeSerialsCount
=
$this
->
getFreeSerialCount
(
$esdId
)
;
$variant
=
$esd
->
getArticleDetail
(
)
;
$variant
->
setInStock
(
$freeSerialsCount
)
;