You are here

public function Product::hasVariations in Commerce Core 8.2

Gets whether the product has variations.

A product must always have at least one variation, but a newly initialized (or invalid) product entity might not have any.

Return value

bool TRUE if the product has variations, FALSE otherwise.

Overrides ProductInterface::hasVariations

File

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

Class

Product
Defines the product entity class.

Namespace

Drupal\commerce_product\Entity

Code

public function hasVariations() {
  return !$this
    ->get('variations')
    ->isEmpty();
}