createVariation() public method

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)
return Sonata\Component\Product\ProductInterface
Example #1
0
 /**
  * Returns a new travel variation entity
  *
  * @param \Sonata\Component\Product\ProductProviderInterface $provider
  * @param \Sonata\Component\Product\ProductInterface $parent
  *
  * @return Travel
  */
 protected function generateDefaultTravelVariation($provider, $parent)
 {
     $entity = $provider->createVariation($parent);
     $entity->setEnabled(true);
     return $entity;
 }