Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setDisplayFromPrice example
$product
->
addAttribute
(
'marketing',
$this
->marketingService->
getProductAttribute
(
$product
)
)
;
$this
->priceCalculationService->
calculateProduct
(
$product
,
$context
)
;
if
(
!
$this
->
isProductValid
(
$product
,
$context
)
)
{
continue
;
}
$product
->
setListingPrice
(
$product
->
getCheapestUnitPrice
(
)
)
;
$product
->
setDisplayFromPrice
(
\
count
(
$product
->
getPrices
(
)
)
> 1 ||
$product
->
hasDifferentPrices
(
)
)
;
$product
->
setAllowBuyInListing
(
$this
->
allowBuyInListing
(
$product
)
)
;
if
(
$this
->config->
get
(
'calculateCheapestPriceWithMinPurchase'
)
&&
$product
->
getCheapestPrice
(
)
instanceof Price
)
{
$product
->
setListingPrice
(
$product
->
getCheapestPrice
(
)
)
;
}
$result
[
$number
]
=
$product
;
}
return
$result
;
}
/** * Checks if the provided product is allowed to display in the store front for * the provided context. */
$cheapestPriceRule
=
$this
->
calculatePriceGroupDiscounts
(
$product
,
$cheapestPriceRule
,
$context
)
;
}
$product
->
setCheapestPriceRule
(
$cheapestPriceRule
)
;
$this
->priceCalculationService->
calculateProduct
(
$product
,
$context
)
;
$product
->
setListingPrice
(
$product
->
getCheapestUnitPrice
(
)
)
;
if
(
$this
->config->
get
(
'calculateCheapestPriceWithMinPurchase'
)
&&
$product
->
getCheapestPrice
(
)
instanceof Price
)
{
$product
->
setListingPrice
(
$product
->
getCheapestPrice
(
)
)
;
}
$product
->
setDisplayFromPrice
(
$displayFromPrice
)
;
}
}
private
function
calculatePriceGroupDiscounts
(
ListProduct
$product
, PriceRule
$price
, ShopContextInterface
$context
)
: PriceRule
{
if
(
!
$product
->
isPriceGroupActive
(
)
)
{
return
$price
;
}
$discount
=
$this
->
getHighestQuantityDiscount
(
$product
,
$context
,
$price
->
getFrom
(
)
)
;
$product
=
$this
->additionalTextService->
buildAdditionalText
(
$product
,
$context
)
;
$this
->
switchPrice
(
$product
)
;
}
$element
->
getData
(
)
->
set
(
'product',
$product
)
;
}
private
function
switchPrice
(
ListProduct
$product
)
: void
{
$prices
=
array_values
(
$product
->
getPrices
(
)
)
;
$product
->
setListingPrice
(
$prices
[
0
]
)
;
$product
->
setDisplayFromPrice
(
\
count
(
$product
->
getPrices
(
)
)
> 1
)
;
if
(
$this
->shopwareConfig->
get
(
'useLastGraduationForCheapestPrice'
)
)
{
$product
->
setListingPrice
(
$prices
[
\
count
(
$prices
)
- 1
]
)
;
}
}
private
function
generateCriteria
(
Element
$element
, ShopContextInterface
$context
)
: Criteria
{
$categoryId
=
(int)
$element
->
getConfig
(
)
->
get
(
'article_category'
)
;
$element
->
getData
(
)
->
set
(
'products',
$products
)
;
break
;
}
}
private
function
switchPrice
(
ListProduct
$product
)
: void
{
$prices
=
array_values
(
$product
->
getPrices
(
)
)
;
$product
->
setListingPrice
(
$prices
[
0
]
)
;
$product
->
setDisplayFromPrice
(
\
count
(
$product
->
getPrices
(
)
)
> 1
)
;
if
(
$this
->shopwareConfig->
get
(
'useLastGraduationForCheapestPrice'
)
)
{
$product
->
setListingPrice
(
$prices
[
\
count
(
$prices
)
- 1
]
)
;
}
}
private
function
generateCriteria
(
Element
$element
, ShopContextInterface
$context
)
: Criteria
{
$type
=
$element
->
getConfig
(
)
->
get
(
self::SLIDER_TYPE_KEY
)
;