Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
sortItemsByPosition example
foreach
(
$sliderItemsConfig
->
getArrayValue
(
)
as
$sliderItem
)
{
$this
->
addDefaultMediaToImageSlider
(
$imageSlider
,
$sliderItem
)
;
}
}
if
(
$sliderItemsConfig
->
isMapped
(
)
&&
$resolverContext
instanceof EntityResolverContext
)
{
$sliderItems
=
$this
->
resolveEntityValue
(
$resolverContext
->
getEntity
(
)
,
$sliderItemsConfig
->
getStringValue
(
)
)
;
if
(
$sliderItems
=== null
||
(
is_countable
(
$sliderItems
)
? \
count
(
$sliderItems
)
: 0
)
< 1
)
{
return
;
}
$this
->
sortItemsByPosition
(
$sliderItems
)
;
if
(
$sliderItemsConfig
->
getStringValue
(
)
=== 'product.media'
)
{
/** @var ProductEntity $productEntity */
$productEntity
=
$resolverContext
->
getEntity
(
)
;
if
(
$productEntity
->
getCover
(
)
)
{
/** @var ProductMediaCollection $sliderItems */
$sliderItems
=
new
ProductMediaCollection
(
array_merge
(
[
$productEntity
->
getCoverId
(
)
=>
$productEntity
->
getCover
(
)
]
,
$sliderItems
->
getElements
(
)
)
)
;
}