Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ImageSliderItemStruct example
if
(
$productEntity
->
getCover
(
)
)
{
/** @var ProductMediaCollection $sliderItems */
$sliderItems
=
new
ProductMediaCollection
(
array_merge
(
[
$productEntity
->
getCoverId
(
)
=>
$productEntity
->
getCover
(
)
]
,
$sliderItems
->
getElements
(
)
)
)
;
}
}
foreach
(
$sliderItems
->
getMedia
(
)
as
$media
)
{
$imageSliderItem
=
new
ImageSliderItemStruct
(
)
;
$imageSliderItem
->
setMedia
(
$media
)
;
$imageSlider
->
addSliderItem
(
$imageSliderItem
)
;
}
}
}
protected
function
sortItemsByPosition
(
ProductMediaCollection
$sliderItems
)
: void
{
if
(
!
$sliderItems
->
first
(
)
|| !
$sliderItems
->
first
(
)
->
has
(
'position'
)
)
{
return
;
}