Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
CrossSellingElement example
$criteria
=
$this
->
handleAvailableStock
(
$criteria
,
$context
)
;
$this
->eventDispatcher->
dispatch
(
new
ProductCrossSellingStreamCriteriaEvent
(
$crossSelling
,
$criteria
,
$context
)
)
;
$searchResult
=
$this
->listingLoader->
load
(
$criteria
,
$context
)
;
/** @var ProductCollection $products */
$products
=
$searchResult
->
getEntities
(
)
;
$element
=
new
CrossSellingElement
(
)
;
$element
->
setCrossSelling
(
$crossSelling
)
;
$element
->
setProducts
(
$products
)
;
$element
->
setStreamId
(
$crossSelling
->
getProductStreamId
(
)
)
;
$element
->
setTotal
(
$products
->
count
(
)
)
;
return
$element
;
}
private
function
loadByIds
(
ProductCrossSellingEntity
$crossSelling
, SalesChannelContext
$context
, Criteria
$criteria
)
: CrossSellingElement
{