PHP Class Sonata\ProductBundle\Twig\Extension\ProductExtension

Author: Sylvain Deloux ([email protected])
Inheritance: extends Twig_Extension
Show file Open project: sonata-project/ecommerce

Protected Properties

Property Type Description
$basketElementClass string
$formFactory Symfony\Component\Form\FormFactoryInterface
$productPool Sonata\Component\Product\Pool

Public Methods

Method Description
__construct ( Pool $productPool, Symfony\Component\Form\FormFactoryInterface $formFactory, string $basketElementClass ) Constructor.
getCheapestEnabledVariation ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductInterface Return the cheapest variation of the product (or itself if none).
getCheapestEnabledVariationPrice ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductInterface Return the cheapest variation price of the product (or itself if none).
getFormAddBasket ( Sonata\Component\Product\ProductInterface $product ) : Symfony\Component\Form\FormView Returns a "add to basket" form for a specified product.
getFunctions ( ) : array
getName ( )
getProductPrice ( Sonata\Component\Product\ProductInterface $product, Sonata\Component\Currency\CurrencyInterface $currency, boolean $vat = false ) : float Return the calculated price of the product.
getProductProvider ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductProviderInterface Return the Provider of the given Product.
getProductStock ( Sonata\Component\Product\ProductInterface $product ) : integer Return the available stock of the product.
hasEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean Check if the product has enabled variations.
hasVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean Check if the product has variations.

Method Details

__construct() public method

Constructor.
public __construct ( Pool $productPool, Symfony\Component\Form\FormFactoryInterface $formFactory, string $basketElementClass )
$productPool Sonata\Component\Product\Pool Sonata product pool
$formFactory Symfony\Component\Form\FormFactoryInterface Symfony form factory
$basketElementClass string Sonata basket element class name

getCheapestEnabledVariation() public method

Return the cheapest variation of the product (or itself if none).
public getCheapestEnabledVariation ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductInterface
$product Sonata\Component\Product\ProductInterface
return Sonata\Component\Product\ProductInterface

getCheapestEnabledVariationPrice() public method

Return the cheapest variation price of the product (or itself if none).
public getCheapestEnabledVariationPrice ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductInterface
$product Sonata\Component\Product\ProductInterface
return Sonata\Component\Product\ProductInterface

getFormAddBasket() public method

Returns a "add to basket" form for a specified product.
public getFormAddBasket ( Sonata\Component\Product\ProductInterface $product ) : Symfony\Component\Form\FormView
$product Sonata\Component\Product\ProductInterface A product instance
return Symfony\Component\Form\FormView

getFunctions() public method

public getFunctions ( ) : array
return array

getName() public method

public getName ( )

getProductPrice() public method

Return the calculated price of the product.
public getProductPrice ( Sonata\Component\Product\ProductInterface $product, Sonata\Component\Currency\CurrencyInterface $currency, boolean $vat = false ) : float
$product Sonata\Component\Product\ProductInterface A product instance
$currency Sonata\Component\Currency\CurrencyInterface A currency instance
$vat boolean Returns price including VAT?
return float

getProductProvider() public method

Return the Provider of the given Product.
public getProductProvider ( Sonata\Component\Product\ProductInterface $product ) : Sonata\Component\Product\ProductProviderInterface
$product Sonata\Component\Product\ProductInterface
return Sonata\Component\Product\ProductProviderInterface

getProductStock() public method

Return the available stock of the product.
public getProductStock ( Sonata\Component\Product\ProductInterface $product ) : integer
$product Sonata\Component\Product\ProductInterface A product instance
return integer

hasEnabledVariations() public method

Check if the product has enabled variations.
public hasEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean
$product Sonata\Component\Product\ProductInterface
return boolean

hasVariations() public method

Check if the product has variations.
public hasVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean
$product Sonata\Component\Product\ProductInterface
return boolean

Property Details

$basketElementClass protected property

protected string $basketElementClass
return string

$formFactory protected property

protected FormFactoryInterface,Symfony\Component\Form $formFactory
return Symfony\Component\Form\FormFactoryInterface

$productPool protected property

protected Pool,Sonata\Component\Product $productPool
return Sonata\Component\Product\Pool