You are here

public function Promotion::createDuplicate in Commerce Core 8.2

Creates a duplicate of the entity.

Return value

static A clone of $this with all identifiers unset, so saving it inserts a new entity into the storage system.

Overrides ContentEntityBase::createDuplicate

File

modules/promotion/src/Entity/Promotion.php, line 112

Class

Promotion
Defines the promotion entity class.

Namespace

Drupal\commerce_promotion\Entity

Code

public function createDuplicate() {
  $duplicate = parent::createDuplicate();

  // Coupons cannot be transferred because their codes are unique.
  $duplicate
    ->set('coupons', []);
  return $duplicate;
}