PHP Interface Sonata\Component\Product\ProductProviderInterface

Afficher le fichier Open project: sonata-project/ecommerce Interface Usage Examples

Méthodes publiques

Méthode Description
basketAddProduct ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, Sonata\Component\Basket\BasketElementInterface $newBasketElement ) return true if the basket element is still valid.
basketMergeProduct ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, Sonata\Component\Basket\BasketElementInterface $newBasketElement ) Merge a product with another when the product is already present into the basket.
buildBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Product\ProductInterface $product = null, array $options = [] )
buildCreateForm ( Sonata\AdminBundle\Form\FormMapper $formMapper )
buildEditForm ( Sonata\AdminBundle\Form\FormMapper $formMapper, boolean $isVariation = false )
buildForm ( Symfony\Component\Form\FormBuilderInterface $builder, array $options, boolean $isVariation = false ) Build form by adding provider fields.
calculatePrice ( Sonata\Component\Product\ProductInterface $product, Sonata\Component\Currency\CurrencyInterface $currency, boolean $vat = false, integer $quantity = 1 ) : float Calculate the product price depending on the currency.
configureShowFields ( Sonata\AdminBundle\Show\ShowMapper $showMapper )
createBasketElement ( Sonata\Component\Product\ProductInterface $product = null, array $options = [] ) : Sonata\Component\Basket\BasketElementInterface
createVariation ( Sonata\Component\Product\ProductInterface $product, boolean $copyDependencies = true ) : Sonata\Component\Product\ProductInterface Creates a variation from a given Product and its dependencies.
defineAddBasketForm ( Sonata\Component\Product\ProductInterface $product, FormBuilder $formBuilder, boolean $showQuantity = true, array $options = [] )
defineBasketElementForm ( Sonata\Component\Basket\BasketElementInterface $basketElement, FormBuilder $formBuilder, array $options = [] )
getBaseControllerName ( ) : string
getBasketElementManager ( ) : Sonata\Component\Basket\BasketElementManagerInterface
getCheapestEnabledVariation ( Sonata\Component\Product\ProductInterface $product ) : null | Sonata\Component\Product\ProductInterface Fetch the cheapest variation if provided/existing.
getEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : ArrayCollection Return the list of enabled product variations.
getFilters ( ) : mixed Gets the fields on which the product might be filtered in the catalog view.
getProductCategoryManager ( ) : Sonata\Component\Product\ProductCategoryManagerInterface
getProductCollectionManager ( ) : Sonata\Component\Product\ProductCollectionManagerInterface
getStockAvailable ( Sonata\Component\Product\ProductInterface $product ) : integer return the stock available for the current product.
getVariatedProperties ( Sonata\Component\Product\ProductInterface $product, array $fields = [] ) : array Gets the properties values of $product amongst variation fields or $fields if set.
getVariation ( Sonata\Component\Product\ProductInterface $product, array $choices = [] ) Gets the variation matching $choices from master product $product.
getVariationsChoices ( Sonata\Component\Product\ProductInterface $product, array $fields = [] ) : array Gets the possible values for $fields (or variation fields if not set).
hasEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean Return true if Product has enabled variation(s).
hasVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean Check if the product has variations.
isAddableToBasket ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, array $options = [] ) : boolean Return true if the product can be added to the provided basket.
isValidBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement ) : boolean
setBasketElementManager ( Sonata\Component\Basket\BasketElementManagerInterface $basketElementManager )
setProductCategoryManager ( Sonata\Component\Product\ProductCategoryManagerInterface $productCategoryManager )
setProductCollectionManager ( Sonata\Component\Product\ProductCollectionManagerInterface $productCollectionManager )
synchronizeVariations ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes all parent Product data to its variations (or a single one if $targetVariation is specified).
synchronizeVariationsCategories ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes parent Product categories to its variations (or a single one if $targetVariation is specified).
synchronizeVariationsCollections ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes parent Product collections to its variations (or a single one if $targetVariation is specified).
synchronizeVariationsDeliveries ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes parent Product deliveries to its variations (or a single one if $targetVariation is specified).
synchronizeVariationsPackages ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes parent Product packages to its variations (or a single one if $targetVariation is specified).
synchronizeVariationsProduct ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null ) Synchronizes parent Product data to its variations (or a single one if $targetVariation is specified).
updateComputationPricesFields ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Product\ProductInterface $product ) Updates basket element different prices computation fields values.
updateStock ( Sonata\Component\Product\ProductInterface | integer $product, Sonata\Component\Product\ProductManagerInterface $productManager, integer $diff ) Update the stock value of a given Product id.
validateFormBasketElement ( Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Basket\BasketInterface $basket ) return an array of errors if any, you can also manipulate the basketElement if require please not you always work with a clone version of the basketElement.

Method Details

basketAddProduct() public méthode

return true if the basket element is still valid.
public basketAddProduct ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, Sonata\Component\Basket\BasketElementInterface $newBasketElement )
$basket Sonata\Component\Basket\BasketInterface
$product Sonata\Component\Product\ProductInterface
$newBasketElement Sonata\Component\Basket\BasketElementInterface

basketMergeProduct() public méthode

Merge a product with another when the product is already present into the basket.
public basketMergeProduct ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, Sonata\Component\Basket\BasketElementInterface $newBasketElement )
$basket Sonata\Component\Basket\BasketInterface
$product Sonata\Component\Product\ProductInterface
$newBasketElement Sonata\Component\Basket\BasketElementInterface

buildBasketElement() public méthode

public buildBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Product\ProductInterface $product = null, array $options = [] )
$basketElement Sonata\Component\Basket\BasketElementInterface
$product Sonata\Component\Product\ProductInterface
$options array

buildCreateForm() public méthode

public buildCreateForm ( Sonata\AdminBundle\Form\FormMapper $formMapper )
$formMapper Sonata\AdminBundle\Form\FormMapper

buildEditForm() public méthode

public buildEditForm ( Sonata\AdminBundle\Form\FormMapper $formMapper, boolean $isVariation = false )
$formMapper Sonata\AdminBundle\Form\FormMapper
$isVariation boolean

buildForm() public méthode

Build form by adding provider fields.
public buildForm ( Symfony\Component\Form\FormBuilderInterface $builder, array $options, boolean $isVariation = false )
$builder Symfony\Component\Form\FormBuilderInterface Symfony form builder
$options array An options array
$isVariation boolean Is the product a variation of a master product?

calculatePrice() public méthode

Calculate the product price depending on the currency.
public calculatePrice ( Sonata\Component\Product\ProductInterface $product, Sonata\Component\Currency\CurrencyInterface $currency, boolean $vat = false, integer $quantity = 1 ) : float
$product Sonata\Component\Product\ProductInterface A product instance
$currency Sonata\Component\Currency\CurrencyInterface A currency instance
$vat boolean Returns price including VAT?
$quantity integer Defaults to one
Résultat float

configureShowFields() public méthode

public configureShowFields ( Sonata\AdminBundle\Show\ShowMapper $showMapper )
$showMapper Sonata\AdminBundle\Show\ShowMapper

createBasketElement() public méthode

public createBasketElement ( Sonata\Component\Product\ProductInterface $product = null, array $options = [] ) : Sonata\Component\Basket\BasketElementInterface
$product Sonata\Component\Product\ProductInterface
$options array
Résultat Sonata\Component\Basket\BasketElementInterface

createVariation() public méthode

Creates a variation from a given Product and its dependencies.
public createVariation ( Sonata\Component\Product\ProductInterface $product, boolean $copyDependencies = true ) : Sonata\Component\Product\ProductInterface
$product Sonata\Component\Product\ProductInterface Product to duplicate
$copyDependencies boolean If false, duplicates only Product (without dependencies)
Résultat Sonata\Component\Product\ProductInterface

defineAddBasketForm() public méthode

public defineAddBasketForm ( Sonata\Component\Product\ProductInterface $product, FormBuilder $formBuilder, boolean $showQuantity = true, array $options = [] )
$product Sonata\Component\Product\ProductInterface A Sonata product instance
$formBuilder Symfony\Component\Form\FormBuilder Symfony form builder
$showQuantity boolean Specifies if quantity field will be displayed (default true)
$options array An options array

defineBasketElementForm() public méthode

public defineBasketElementForm ( Sonata\Component\Basket\BasketElementInterface $basketElement, FormBuilder $formBuilder, array $options = [] )
$basketElement Sonata\Component\Basket\BasketElementInterface
$formBuilder Symfony\Component\Form\FormBuilder
$options array

getBaseControllerName() public méthode

public getBaseControllerName ( ) : string
Résultat string

getBasketElementManager() public méthode

public getBasketElementManager ( ) : Sonata\Component\Basket\BasketElementManagerInterface
Résultat Sonata\Component\Basket\BasketElementManagerInterface

getCheapestEnabledVariation() public méthode

Fetch the cheapest variation if provided/existing.
public getCheapestEnabledVariation ( Sonata\Component\Product\ProductInterface $product ) : null | Sonata\Component\Product\ProductInterface
$product Sonata\Component\Product\ProductInterface
Résultat null | Sonata\Component\Product\ProductInterface

getEnabledVariations() public méthode

Return the list of enabled product variations.
public getEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : ArrayCollection
$product Sonata\Component\Product\ProductInterface
Résultat Doctrine\Common\Collections\ArrayCollection

getFilters() public méthode

Gets the fields on which the product might be filtered in the catalog view.
public getFilters ( ) : mixed
Résultat mixed

getProductCategoryManager() public méthode

public getProductCategoryManager ( ) : Sonata\Component\Product\ProductCategoryManagerInterface
Résultat Sonata\Component\Product\ProductCategoryManagerInterface

getProductCollectionManager() public méthode

public getProductCollectionManager ( ) : Sonata\Component\Product\ProductCollectionManagerInterface
Résultat Sonata\Component\Product\ProductCollectionManagerInterface

getStockAvailable() public méthode

return the stock available for the current product.
public getStockAvailable ( Sonata\Component\Product\ProductInterface $product ) : integer
$product Sonata\Component\Product\ProductInterface
Résultat integer the stock available

getVariatedProperties() public méthode

Gets the properties values of $product amongst variation fields or $fields if set.
public getVariatedProperties ( Sonata\Component\Product\ProductInterface $product, array $fields = [] ) : array
$product Sonata\Component\Product\ProductInterface
$fields array
Résultat array

getVariation() public méthode

Gets the variation matching $choices from master product $product.
public getVariation ( Sonata\Component\Product\ProductInterface $product, array $choices = [] )
$product Sonata\Component\Product\ProductInterface
$choices array

getVariationsChoices() public méthode

Gets the possible values for $fields (or variation fields if not set).
public getVariationsChoices ( Sonata\Component\Product\ProductInterface $product, array $fields = [] ) : array
$product Sonata\Component\Product\ProductInterface
$fields array
Résultat array

hasEnabledVariations() public méthode

Return true if Product has enabled variation(s).
public hasEnabledVariations ( Sonata\Component\Product\ProductInterface $product ) : boolean
$product Sonata\Component\Product\ProductInterface
Résultat boolean

hasVariations() public méthode

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

isAddableToBasket() public méthode

Return true if the product can be added to the provided basket.
public isAddableToBasket ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Product\ProductInterface $product, array $options = [] ) : boolean
$basket Sonata\Component\Basket\BasketInterface
$product Sonata\Component\Product\ProductInterface
$options array
Résultat boolean

isValidBasketElement() public méthode

public isValidBasketElement ( Sonata\Component\Basket\BasketElementInterface $basketElement ) : boolean
$basketElement Sonata\Component\Basket\BasketElementInterface
Résultat boolean true if the basket element is still valid

setBasketElementManager() public méthode

public setBasketElementManager ( Sonata\Component\Basket\BasketElementManagerInterface $basketElementManager )
$basketElementManager Sonata\Component\Basket\BasketElementManagerInterface

setProductCategoryManager() public méthode

public setProductCategoryManager ( Sonata\Component\Product\ProductCategoryManagerInterface $productCategoryManager )
$productCategoryManager Sonata\Component\Product\ProductCategoryManagerInterface

setProductCollectionManager() public méthode

public setProductCollectionManager ( Sonata\Component\Product\ProductCollectionManagerInterface $productCollectionManager )
$productCollectionManager Sonata\Component\Product\ProductCollectionManagerInterface

synchronizeVariations() public méthode

Synchronizes all parent Product data to its variations (or a single one if $targetVariation is specified).
public synchronizeVariations ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

synchronizeVariationsCategories() public méthode

Synchronizes parent Product categories to its variations (or a single one if $targetVariation is specified).
public synchronizeVariationsCategories ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

synchronizeVariationsCollections() public méthode

Synchronizes parent Product collections to its variations (or a single one if $targetVariation is specified).
public synchronizeVariationsCollections ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

synchronizeVariationsDeliveries() public méthode

Synchronizes parent Product deliveries to its variations (or a single one if $targetVariation is specified).
public synchronizeVariationsDeliveries ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

synchronizeVariationsPackages() public méthode

Synchronizes parent Product packages to its variations (or a single one if $targetVariation is specified).
public synchronizeVariationsPackages ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

synchronizeVariationsProduct() public méthode

Synchronizes parent Product data to its variations (or a single one if $targetVariation is specified).
public synchronizeVariationsProduct ( Sonata\Component\Product\ProductInterface $product, ArrayCollection $variations = null )
$product Sonata\Component\Product\ProductInterface Parent Product
$variations Doctrine\Common\Collections\ArrayCollection Optional target variations to synchronize

updateComputationPricesFields() public méthode

Updates basket element different prices computation fields values.
public updateComputationPricesFields ( Sonata\Component\Basket\BasketInterface $basket, Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Product\ProductInterface $product )
$basket Sonata\Component\Basket\BasketInterface A basket instance
$basketElement Sonata\Component\Basket\BasketElementInterface A basket element instance
$product Sonata\Component\Product\ProductInterface A product instance

updateStock() public méthode

Update the stock value of a given Product id.
public updateStock ( Sonata\Component\Product\ProductInterface | integer $product, Sonata\Component\Product\ProductManagerInterface $productManager, integer $diff )
$product Sonata\Component\Product\ProductInterface | integer
$productManager Sonata\Component\Product\ProductManagerInterface
$diff integer

validateFormBasketElement() public méthode

If the basket is valid it will then replace the one in session
public validateFormBasketElement ( Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\Component\Basket\BasketElementInterface $basketElement, Sonata\Component\Basket\BasketInterface $basket )
$errorElement Sonata\CoreBundle\Validator\ErrorElement
$basketElement Sonata\Component\Basket\BasketElementInterface
$basket Sonata\Component\Basket\BasketInterface