You are here

public function Product::hasVariation in Commerce Core 8.2

Checks whether the product has a given variation.

Parameters

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

Return value

bool TRUE if the variation was found, FALSE otherwise.

Overrides ProductInterface::hasVariation

1 call to Product::hasVariation()
Product::addVariation in modules/product/src/Entity/Product.php
Adds a variation.

File

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

Class

Product
Defines the product entity class.

Namespace

Drupal\commerce_product\Entity

Code

public function hasVariation(ProductVariationInterface $variation) {
  return in_array($variation
    ->id(), $this
    ->getVariationIds());
}