Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getConfiguratorPriceVariationsQuery example
public
function
getArticlePriceVariations
(
$configuratorSetId
)
{
$variationRules
=
$this
->
get
(
'models'
)
->
getRepository
(
Article::
class
)
->
getConfiguratorPriceVariationsQuery
(
$configuratorSetId
)
->
getArrayResult
(
)
;
foreach
(
$variationRules
as
&
$variationRule
)
{
$variationRule
=
$this
->
explodePriceVariation
(
$variationRule
)
;
}
return
$variationRules
;
}
public
function
createPriceVariationAction
(
)
{
$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
;
}
$sql
=
$generatorData
[
'sql'
]
;
$originals
=
$generatorData
[
'originals'
]
;
$variants
=
Shopware
(
)
->
Db
(
)
->
fetchAll
(
$sql
)
;
$counter
= 1;
if
(
$mergeType
=== 1
)
{