Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
calculateCheapestAvailablePrice example
$rules
=
$product
->
getPriceRules
(
)
;
if
(
!
$product
->
getCheapestPriceRule
(
)
&& !
empty
(
$rules
)
)
{
$product
->
setCheapestPriceRule
(
clone
$rules
[
0
]
)
;
}
if
(
$product
->
getCheapestPriceRule
(
)
)
{
/** * Calculation with considering min purchase */
$rule
=
clone
$product
->
getCheapestPriceRule
(
)
;
$product
->
setCheapestPrice
(
$this
->
calculateCheapestAvailablePrice
(
$product
,
$rule
,
$context
)
)
;
/** * Calculation without considering min purchase */
$rule
=
clone
$product
->
getCheapestPriceRule
(
)
;
$product
->
setCheapestUnitPrice
(
$this
->
calculatePriceStruct
(
$rule
,
$tax
,
$context
)
)
;
}