You are here

protected function ProductBundleItem::getVariationIndex in Commerce Product Bundle 8

Get the index of a variation in the variation references.

Parameters

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

Return value

false|int|string The key for the variation if it is found in the references, false otherwise.

2 calls to ProductBundleItem::getVariationIndex()
ProductBundleItem::hasVariation in src/Entity/ProductBundleItem.php
Whether the bundle item has a specific variation referenced.
ProductBundleItem::removeVariation in src/Entity/ProductBundleItem.php
Removes a variation.

File

src/Entity/ProductBundleItem.php, line 349

Class

ProductBundleItem
Defines the product bundle item entity.

Namespace

Drupal\commerce_product_bundle\Entity

Code

protected function getVariationIndex(ProductVariationInterface $variation) {
  $result = array_search($variation
    ->id(), $this
    ->getVariationIds() ?: []);
  return $result;
}