Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getMaxWeight example
$this
->variantHelper->
joinVariants
(
$query
)
;
$min
= ':minLength' .
md5
(
json_encode
(
$condition
, JSON_THROW_ON_ERROR
)
)
;
$max
= ':maxLength' .
md5
(
json_encode
(
$condition
, JSON_THROW_ON_ERROR
)
)
;
if
(
$condition
->
getMinWeight
(
)
> 0
)
{
$query
->
andWhere
(
'allVariants.weight >= ' .
$min
)
;
$query
->
setParameter
(
$min
,
$condition
->
getMinWeight
(
)
)
;
}
if
(
$condition
->
getMaxWeight
(
)
> 0
)
{
$query
->
andWhere
(
'allVariants.weight <= ' .
$max
)
;
$query
->
setParameter
(
$max
,
$condition
->
getMaxWeight
(
)
)
;
}
}
}
ShopContextInterface
$context
)
{
$search
->
addPostFilter
(
$this
->
getQuery
(
$criteriaPart
)
)
;
}
private
function
getQuery
(
WeightCondition
$criteriaPart
)
: RangeQuery
{
$range
=
[
]
;
if
(
$criteriaPart
->
getMinWeight
(
)
)
{
$range
[
'gte'
]
=
$criteriaPart
->
getMinWeight
(
)
;
}
if
(
$criteriaPart
->
getMaxWeight
(
)
)
{
$range
[
'lte'
]
=
$criteriaPart
->
getMaxWeight
(
)
;
}
return
new
RangeQuery
(
'weight',
$range
)
;
}
}