Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getMaxHeight example
$min
= ':minHeight' .
md5
(
json_encode
(
$condition
, JSON_THROW_ON_ERROR
)
)
;
$max
= ':maxHeight' .
md5
(
json_encode
(
$condition
, JSON_THROW_ON_ERROR
)
)
;
$this
->variantHelper->
joinVariants
(
$query
)
;
if
(
$condition
->
getMinHeight
(
)
> 0
)
{
$query
->
andWhere
(
'allVariants.height >= ' .
$min
)
;
$query
->
setParameter
(
$min
,
$condition
->
getMinHeight
(
)
)
;
}
if
(
$condition
->
getMaxHeight
(
)
> 0
)
{
$query
->
andWhere
(
'allVariants.height <= ' .
$max
)
;
$query
->
setParameter
(
$max
,
$condition
->
getMaxHeight
(
)
)
;
}
}
}
ShopContextInterface
$context
)
{
$search
->
addPostFilter
(
$this
->
getQuery
(
$criteriaPart
)
)
;
}
private
function
getQuery
(
HeightCondition
$criteriaPart
)
: RangeQuery
{
$range
=
[
]
;
if
(
$criteriaPart
->
getMinHeight
(
)
)
{
$range
[
'gte'
]
=
$criteriaPart
->
getMinHeight
(
)
;
}
if
(
$criteriaPart
->
getMaxHeight
(
)
)
{
$range
[
'lte'
]
=
$criteriaPart
->
getMaxHeight
(
)
;
}
return
new
RangeQuery
(
'height',
$range
)
;
}
}
return
[
]
;
}
$thumbnails
=
[
]
;
foreach
(
$media
->
getThumbnails
(
)
as
$thumbnail
)
{
$thumbnails
[
]
=
[
'source' =>
$thumbnail
->
getSource
(
)
,
'retinaSource' =>
$thumbnail
->
getRetinaSource
(
)
,
'sourceSet' =>
$this
->
getSourceSet
(
$thumbnail
)
,
'maxWidth' =>
$thumbnail
->
getMaxWidth
(
)
,
'maxHeight' =>
$thumbnail
->
getMaxHeight
(
)
,
'attributes' =>
$thumbnail
->
getAttributes
(
)
,
]
;
}
$data
=
[
'id' =>
$media
->
getId
(
)
,
'position' => null,
'source' =>
$media
->
getFile
(
)
,
'description' =>
$media
->
getName
(
)
,
'extension' =>
$media
->
getExtension
(
)
,
'main' =>
$media
->
isPreview
(
)
,