Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getConfiguratorSetRepository example
$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
(
)
;
$builder
=
$this
->
get
(
'models'
)
->
createQueryBuilder
(
)
;
$data
=
$builder
->
select
(
[
'dependency', 'dependencyParent', 'dependencyChild'
]
)
->
from
(
Dependency::
class
, 'dependency'
)
->
leftJoin
(
'dependency.parentOption', 'dependencyParent'
)
->
leftJoin
(
'dependency.childOption', 'dependencyChild'
)
->
where
(
'dependency.id = ?1'
)
->
setParameter
(
1,
$dependency
->
getId
(
)
)