You are here

public function ProductBundleItem::getVariations in Commerce Product Bundle 8

Gets the product variations limited by the bundle item or enabled on the product.

This method returns the variations, if any, specified (limited) by the bundle item, or fall back to all enabled variations of the referenced product.

Return value

\Drupal\commerce_product\Entity\ProductVariationInterface[] The product variations.

Overrides BundleItemInterface::getVariations

2 calls to ProductBundleItem::getVariations()
ProductBundleItem::getDefaultVariation in src/Entity/ProductBundleItem.php
Get the default variation.
ProductBundleItem::getVariationIds in src/Entity/ProductBundleItem.php
Gets the variation IDs.

File

src/Entity/ProductBundleItem.php, line 400

Class

ProductBundleItem
Defines the product bundle item entity.

Namespace

Drupal\commerce_product_bundle\Entity

Code

public function getVariations() {
  if (!$this
    ->hasProduct()) {
    return NULL;
  }
  $variations = $this
    ->get('variations')
    ->referencedEntities();
  if (empty($variations)) {
    return $this
      ->getEnabledVariations();
  }
  return $this
    ->ensureTranslations($variations);
}