Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getCrossSelling example
$this
->productRepository->
create
(
[
$productData
]
,
$this
->salesChannelContext->
getContext
(
)
)
;
$result
=
$this
->route->
load
(
$productId
,
new
Request
(
)
,
$this
->salesChannelContext,
new
Criteria
(
)
)
->
getResult
(
)
;
static
::
assertEquals
(
1,
$result
->
count
(
)
)
;
$element
=
$result
->
first
(
)
;
static
::
assertNotNull
(
$element
)
;
static
::
assertEquals
(
3,
$element
->
getTotal
(
)
)
;
static
::
assertEquals
(
'Test Cross Selling',
$element
->
getCrossSelling
(
)
->
getName
(
)
)
;
$lastPrice
= 0;
foreach
(
$element
->
getProducts
(
)
as
$product
)
{
$productPrice
=
$product
->
getCurrencyPrice
(
Defaults::CURRENCY
)
;
static
::
assertNotNull
(
$productPrice
)
;
static
::
assertGreaterThanOrEqual
(
$lastPrice
,
$productPrice
->
getGross
(
)
)
;
$lastPrice
=
$productPrice
->
getGross
(
)
;
}
}
public
function
testLoadForProduct
(
)
: void
{