Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setDetailDataReferences example
if
(
$offset
=== 0 &&
$mergeType
=== 1
)
{
$this
->
removeAllConfiguratorVariants
(
$productId
)
;
}
elseif
(
$offset
=== 0 &&
$mergeType
=== 2
)
{
$this
->
deleteVariantsForAllDeactivatedOptions
(
$product
,
$generatorData
[
'allOptions'
]
)
;
}
$this
->
get
(
'models'
)
->
clear
(
)
;
$product
=
$this
->
getRepository
(
)
->
find
(
$productId
)
;
if
(
!
$product
instanceof Product
)
{
throw
new
ModelNotFoundException
(
Product::
class
,
$productId
)
;
}
$detailData
=
$this
->
setDetailDataReferences
(
$detailData
,
$product
)
;
$configuratorSet
=
$product
->
getConfiguratorSet
(
)
;
if
(
!
$configuratorSet
instanceof Set
)
{
throw
new
Exception
(
sprintf
(
'Should not happen. The product with the given ID "%s" must be a variant product at this point.',
$productId
)
)
;
}
$dependencies
=
$this
->
getRepository
(
)
->
getConfiguratorDependenciesQuery
(
$configuratorSet
->
getId
(
)
)
->
getArrayResult
(
)
;
$priceVariations
=
$this
->
getRepository
(
)
->
getConfiguratorPriceVariationsQuery
(
$configuratorSet
->
getId
(
)
)
->
getArrayResult
(
)
;
if
(
empty
(
$generatorData
)
)
{
return
;
}