You are here

protected function CommerceAutoSkuGeneratorBase::getBundleLabel in Commerce AutoSKU 8.2

Gets the entity bundle label or the entity label.

Return value

string The bundle label.

1 call to CommerceAutoSkuGeneratorBase::getBundleLabel()
CommerceAutoSkuGeneratorBase::getAlternativeSku in src/Plugin/CommerceAutoSkuGenerator/CommerceAutoSkuGeneratorBase.php
Gets an alternative SKU.

File

src/Plugin/CommerceAutoSkuGenerator/CommerceAutoSkuGeneratorBase.php, line 113

Class

CommerceAutoSkuGeneratorBase
Places an order through a series of steps.

Namespace

Drupal\commerce_autosku\Plugin\CommerceAutoSkuGenerator

Code

protected function getBundleLabel(ProductVariationInterface $entity) {
  $entity_type = $entity
    ->getEntityTypeId();
  $bundle = $entity
    ->bundle();

  // Use the the human readable name of the bundle type. If this entity has no
  // bundle, we use the name of the content entity type.
  if ($bundle != $entity_type) {
    $bundle_entity_type = $this->entityTypeManager
      ->getDefinition($entity_type)
      ->getBundleEntityType();
    $label = $this->entityTypeManager
      ->getStorage($bundle_entity_type)
      ->load($bundle)
      ->label();
  }
  else {
    $label = $this->entityTypeManager
      ->getDefinition($entity_type)
      ->getLabel();
  }
  return $label;
}