You are here

public function UnpublishProduct::execute in Commerce Core 8.2

Executes the plugin.

Overrides ExecutableInterface::execute

File

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

Class

UnpublishProduct
Unpublishes a product.

Namespace

Drupal\commerce_product\Plugin\Action

Code

public function execute($entity = NULL) {

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