You are here

public function PublishProduct::execute in Commerce Core 8.2

Executes the plugin.

Overrides ExecutableInterface::execute

File

modules/product/src/Plugin/Action/PublishProduct.php, line 22

Class

PublishProduct
Publishes a product.

Namespace

Drupal\commerce_product\Plugin\Action

Code

public function execute($entity = NULL) {

  /** @var \Drupal\commerce_product\Entity\ProductInterface $entity */
  $entity
    ->setPublished(TRUE);
  $entity
    ->save();
}