modules/acm_customer/src/Commands/AcmCustomerDrushCommands.php
public function pushCustomersData() {
    $query = $this->connection->select('users_field_data', 'user');
    $query->addField('user', 'mail');
    $query->condition('status', 0, '>');
    $query->condition('acm_customer_id', 0, '>');
    $result = $query->countQuery()->execute()->fetchAssoc();

    if ($result['expression'] == 0) {
      $this->logger->warning('No customers with active status available to push.');
      return;
    }

    $question = dt('There are @count customers as of now, are you sure you want to push for all?', [
      '@count' => $result['expression'],
    ]);

    if (!$this->confirm($question)) {
      throw new UserAbortException();
    }

    $query = $this->connection->select('users_field_data', 'user');
    $query->addField('user', 'mail');
    $query->condition('status', 0, '>');
    $query->condition('acm_customer_id', 0, '>');
    $result = $query->execute()->fetchAll(\PDO::FETCH_ASSOC);

    $customers = array_column($result, 'mail');

    $batch = [
      'title' => 'Push Customers Data',
      'init_message' => 'Pushing customers data...',
      'error_message' => 'Error occurred while pushing customers, please check logs.',
    ];

    foreach (array_chunk($customers, self::BATCH_SIZE) as $customers_batch) {
      $batch['operations'][] = [
        [__CLASS__, 'pushCustomerDataInBatch'],
        [$customers_batch],
      ];
    }

    batch_set($batch);
    drush_backend_batch_process();

    $this->logger()->info('Finished pushing customers data, please check logs for more details.');
  }
public function pushCustomersData() {
    $query = $this->connection->select('users_field_data', 'user');
    $query->addField('user', 'mail');
    $query->condition('status', 0, '>');
    $query->condition('acm_customer_id', 0, '>');
    $result = $query->countQuery()->execute()->fetchAssoc();

    if ($result['expression'] == 0) {
      $this->logger->warning('No customers with active status available to push.');
      return;
    }

    $question = dt('There are @count customers as of now, are you sure you want to push for all?', [
      '@count' => $result['expression'],
    ]);

    if (!$this->confirm($question)) {
      throw new UserAbortException();
    }

    $query = $this->connection->select('users_field_data', 'user');
    $query->addField('user', 'mail');
    $query->condition('status', 0, '>');
    $query->condition('acm_customer_id', 0, '>');
    $result = $query->execute()->fetchAll(\PDO::FETCH_ASSOC);

    $customers = array_column($result, 'mail');

    $batch = [
      'title' => 'Push Customers Data',
      'init_message' => 'Pushing customers data...',
      'error_message' => 'Error occurred while pushing customers, please check logs.',
    ];

    foreach (array_chunk($customers, self::BATCH_SIZE) as $customers_batch) {
      $batch['operations'][] = [
        [__CLASS__, 'pushCustomerDataInBatch'],
        [$customers_batch],
      ];
    }

    batch_set($batch);
    drush_backend_batch_process();

    $this->logger()->info('Finished pushing customers data, please check logs for more details.');
  }
public function pushCustomersData ( ) { $ query = $ this -> connection -> select ( 'users_field_data' , 'user' ) ; $ query -> addField ( 'user' , 'mail' ) ; $ query -> condition ( 'status' , 0 , '>' ) ; $ query -> condition ( 'acm_customer_id' , 0 , '>' ) ; $ result = $ query -> countQuery ( ) -> execute ( ) -> fetchAssoc ( ) ; if ( $ result [ 'expression' ] == 0 ) { $ this -> logger -> warning ( 'No customers with active status available to push.' ) ; return ; } $ question = dt ( 'There are @count customers as of now, are you sure you want to push for all?' , [ '@count' => $ result [ 'expression' ] , ] ) ; if ( ! $ this -> confirm ( $ question ) ) { throw new UserAbortException ( ) ; } $ query = $ this -> connection -> select ( 'users_field_data' , 'user' ) ; $ query -> addField ( 'user' , 'mail' ) ; $ query -> condition ( 'status' , 0 , '>' ) ; $ query -> condition ( 'acm_customer_id' , 0 , '>' ) ; $ result = $ query -> execute ( ) -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ customers = array_column ( $ result , 'mail' ) ; $ batch = [ 'title' => 'Push Customers Data' , 'init_message' => 'Pushing customers data...' , 'error_message' => 'Error occurred while pushing customers, please check logs.' , ] ; foreach ( array_chunk ( $ customers , self :: BATCH_SIZE ) as $ customers_batch ) { $ batch [ 'operations' ] [ ] = [ [ __CLASS__ , 'pushCustomerDataInBatch' ] , [ $ customers_batch ] , ] ; } batch_set ( $ batch ) ; drush_backend_batch_process ( ) ; $ this -> logger ( ) -> info ( 'Finished pushing customers data, please check logs for more details.' ) ; }
Push all the customers available in Drupal to upstream system.

@command acm_customer:push-customers

@validate-module-enabled acm_customer

@aliases push-customers

@usage drush push-customers
Push all the customers available in Drupal to upstream system.
Push all the customers available in Drupal to upstream system .