public function ProductBundleItem::setCurrentVariation in Commerce Product Bundle 8
Gets the currently selected variation, or the default variation.
Parameters
\Drupal\commerce_product\Entity\ProductVariationInterface $variation: The variation.
Return value
$this
Throws
\InvalidArgumentException In case the variation passed as argument is not referenced by the bundle item.
Overrides BundleItemInterface::setCurrentVariation
File
- src/
Entity/ ProductBundleItem.php, line 478
Class
- ProductBundleItem
- Defines the product bundle item entity.
Namespace
Drupal\commerce_product_bundle\EntityCode
public function setCurrentVariation(ProductVariationInterface $variation) {
$this
->assertSameProduct([
$variation,
]);
if (!$this
->hasVariation($variation)) {
throw new \InvalidArgumentException('Variation is not part of this product bundle.');
}
$this->currentVariation = $variation;
return $this;
}