You are here

public function CommerceAutoSkuGeneratorBase::generate in Commerce AutoSKU 8.2

Generates the SKU according to the settings.

Parameters

ProductVariationInterface $entity: Content entity.

Return value

string A label string

Overrides CommerceAutoSkuGeneratorInterface::generate

File

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

Class

CommerceAutoSkuGeneratorBase
Places an order through a series of steps.

Namespace

Drupal\commerce_autosku\Plugin\CommerceAutoSkuGenerator

Code

public function generate(ProductVariationInterface $entity) {
  $generated_sku = $this
    ->getSku($entity);
  if (empty($generated_sku)) {
    $generated_sku = $this
      ->getAlternativeSku($entity);
  }
  return $this
    ->makeUnique($entity, $generated_sku);
}