Product script services reference
Shopware\Core\Content\Product\Hook\Pricing\PriceCollectionFacade
The PriceCollectionFacade is a wrapper around the calculated price collection of a product. It allows to manipulate the quantity prices by resetting or changing the price collection.
reset()
- The
reset()
functions allows to reset the complete price collection.
change()
The
change()
function allows a complete overwrite of the product quantity pricesArguments:
array
changes:
Examples:
Overwrite the product prices with a new quantity price graduation
twig{% do debug.dump(product.calculatedPrice.unit, 'discount') %} {% do product.calculatedPrice.surcharge(10) %} {% do debug.dump(product.calculatedPrice.unit, 'surcharge') %}
count()
The
count()
function returns the number of prices which are stored inside this collection.Returns
int
Returns the number of prices which are stored inside this collection
Shopware\Core\Content\Product\Hook\Pricing\ProductProxy
The ProductProxy
is a wrapper for the SalesChannelProductEntity
. It provides access to all properties of the product, but also wraps some data into helper facade classes like PriceFacade
or PriceCollectionFacade
.
__get()
The
__get()
function allows access to all properties of the SalesChannelProductEntityReturns
mixed
|null
Returns the value of the property. The value is
mixed
due to the fact that all properties are accessed via__get()
Arguments:
string
name: Name of the property to access
Examples:
Access the product properties
twig{ to: 30, price: services.price.create({ 'default': { 'gross': 10, 'net': 10} }) }, { to: null, price: services.price.create({ 'default': { 'gross': 5, 'net': 5} }) }, ]) %}
calculatedCheapestPrice()
The
calculatedCheapestPrice
property returns the cheapest price of the product. The price object will be wrapped into aPriceFacade
object which allows to manipulate the price.Returns
Shopware\Core\Checkout\Cart\Facade\PriceFacade
|null
Returns a
PriceFacade
if the product has a calculated cheapest price, otherwisenull
calculatedPrice()
The
calculatedPrice
property returns the price of the product. The price object will be wrapped into aPriceFacade
object which allows to manipulate the price.Returns
Shopware\Core\Checkout\Cart\Facade\PriceFacade
|null
Returns a
PriceFacade
if the product has a price, otherwisenull
calculatedPrices()
The
calculatedPrices
property returns the price of the product. The price object will be wrapped into aPriceCollectionFacade
object which allows to manipulate the collection.Returns
Shopware\Core\Content\Product\Hook\Pricing\PriceCollectionFacade
|null
Returns a
PriceCollectionFacade
if the product has graduated prices, otherwisenull