public function ProductBundleItem::getDefaultVariation in Commerce Product Bundle 8
Get the default variation.
Return value
\Drupal\commerce_product\Entity\ProductVariationInterface The default product variation.
Overrides BundleItemInterface::getDefaultVariation
1 call to ProductBundleItem::getDefaultVariation()
- ProductBundleItem::getCurrentVariation in src/
Entity/ ProductBundleItem.php - @todo Figure out how to get the currently selected variation without holding state in this object.
File
- src/
Entity/ ProductBundleItem.php, line 385
Class
- ProductBundleItem
- Defines the product bundle item entity.
Namespace
Drupal\commerce_product_bundle\EntityCode
public function getDefaultVariation() {
if (!$this
->hasProduct()) {
return NULL;
}
foreach ($this
->getVariations() as $variation) {
// Return the first active variation.
if ($variation
->isPublished()) {
return $variation;
}
}
}