You are here

public function CommerceSmartImporerService::productEraser in Commerce Smart Importer 8

Caution: Erases first 70 products on site.

File

src/Plugin/CommerceSmartImporerService.php, line 1751
Main Commerce Smart Importer Service.

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function productEraser($number) {
  $results = $this->database
    ->select('commerce_product')
    ->fields('commerce_product', [
    'product_id',
  ])
    ->range(0, $number)
    ->execute()
    ->fetchAll();
  $ids = [];
  foreach ($results as $result) {
    $ids[] = $result->product_id;
  }
  $products = Product::loadMultiple($ids);
  foreach ($products as $result) {
    $result
      ->delete();
  }
}