You are here

public function Product::removeVariation in Commerce Core 8.2

Removes a variation.

Parameters

\Drupal\commerce_product\Entity\ProductVariationInterface $variation: The variation.

Return value

$this

Overrides ProductInterface::removeVariation

File

modules/product/src/Entity/Product.php, line 206

Class

Product
Defines the product entity class.

Namespace

Drupal\commerce_product\Entity

Code

public function removeVariation(ProductVariationInterface $variation) {
  $index = $this
    ->getVariationIndex($variation);
  if ($index !== FALSE) {
    $this
      ->get('variations')
      ->offsetUnset($index);
  }
  return $this;
}