Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getConfiguratorDependencyRepository example
/** * Event listener function of the product backend module. Fired when the user saves or updates * an product configurator dependency in the dependency window. */
public
function
saveConfiguratorDependencyAction
(
)
{
$data
=
$this
->
Request
(
)
->
getParams
(
)
;
$id
=
(int)
$this
->
Request
(
)
->
getParam
(
'id'
)
;
$dependency
= null;
if
(
$id
> 0
)
{
$dependency
=
$this
->
getConfiguratorDependencyRepository
(
)
->
find
(
$id
)
;
}
if
(
!
$dependency
instanceof Dependency
)
{
$dependency
=
new
Dependency
(
)
;
}
$data
[
'childOption'
]
=
$this
->
getConfiguratorOptionRepository
(
)
->
find
(
$data
[
'childId'
]
)
;
$data
[
'parentOption'
]
=
$this
->
getConfiguratorOptionRepository
(
)
->
find
(
$data
[
'parentId'
]
)
;
$data
[
'configuratorSet'
]
=
$this
->
getConfiguratorSetRepository
(
)
->
find
(
$data
[
'configuratorSetId'
]
)
;
$dependency
->
fromArray
(
$data
)
;
$this
->
get
(
'models'
)
->
persist
(
$dependency
)
;
$this
->
get
(
'models'
)
->
flush
(
)
;