modules/acm_sku/src/Commands/AcmSkuDrushCommands.php
public function syncProducts($langcode, $page_size, array $options = ['skus' => NULL, 'category_id' => NULL]) {
    $langcode = strtolower($langcode);

    $store_id = $this->i18nhelper->getStoreIdFromLangcode($langcode);

    if (empty($store_id)) {
      $this->output->writeln(dt("Store id not found for provided language code."));
      return;
    }

    $page_size = (int) $page_size;

    if ($page_size <= 0) {
      $this->output->writeln(dt("Page size must be a positive integer."));
      return;
    }

    $skus = $options['skus'];

    $category_id = $options['category_id'];

    // Apply only one filer at a time.
    if ($category_id) {
      $skus = '';
    }

    // Ask for confirmation from user if attempt is to run full sync.
    if (empty($skus) && empty($category_id)) {
      $confirmation_text = dt('I CONFIRM');
      $input = $this->io()->ask(dt('Are you sure you want to import all products for @language language? If yes, type: "@confirmation"', [
        '@language' => $langcode,
        '@confirmation' => $confirmation_text,
      ]));

      if ($input != $confirmation_text) {
        throw new UserAbortException(dt('Please be more attentive in using this command and prove you are not sleep working...'));
      }
    }

    $this->output->writeln(dt('Requesting all commerce products for selected language code...'));
    $this->ingestApiWrapper->productFullSync($store_id, $langcode, $skus, $category_id, $page_size);
    $this->output->writeln(dt('Done.'));
  }
public function syncProducts($langcode, $page_size, array $options = ['skus' => NULL, 'category_id' => NULL]) {
    $langcode = strtolower($langcode);

    $store_id = $this->i18nhelper->getStoreIdFromLangcode($langcode);

    if (empty($store_id)) {
      $this->output->writeln(dt("Store id not found for provided language code."));
      return;
    }

    $page_size = (int) $page_size;

    if ($page_size <= 0) {
      $this->output->writeln(dt("Page size must be a positive integer."));
      return;
    }

    $skus = $options['skus'];

    $category_id = $options['category_id'];

    // Apply only one filer at a time.
    if ($category_id) {
      $skus = '';
    }

    // Ask for confirmation from user if attempt is to run full sync.
    if (empty($skus) && empty($category_id)) {
      $confirmation_text = dt('I CONFIRM');
      $input = $this->io()->ask(dt('Are you sure you want to import all products for @language language? If yes, type: "@confirmation"', [
        '@language' => $langcode,
        '@confirmation' => $confirmation_text,
      ]));

      if ($input != $confirmation_text) {
        throw new UserAbortException(dt('Please be more attentive in using this command and prove you are not sleep working...'));
      }
    }

    $this->output->writeln(dt('Requesting all commerce products for selected language code...'));
    $this->ingestApiWrapper->productFullSync($store_id, $langcode, $skus, $category_id, $page_size);
    $this->output->writeln(dt('Done.'));
  }
public function syncProducts ( $ langcode , $ page_size , array $ options = [ 'skus' => NULL , 'category_id' => NULL ] ) { $ langcode = strtolower ( $ langcode ) ; $ store_id = $ this -> i18nhelper -> getStoreIdFromLangcode ( $ langcode ) ; if ( empty ( $ store_id ) ) { $ this -> output -> writeln ( dt ( "Store id not found for provided language code." ) ) ; return ; } $ page_size = ( int ) $ page_size ; if ( $ page_size <= 0 ) { $ this -> output -> writeln ( dt ( "Page size must be a positive integer." ) ) ; return ; } $ skus = $ options [ 'skus' ] ; $ category_id = $ options [ 'category_id' ] ; // Apply only one filer at a time. if ( $ category_id ) { $ skus = '' ; } // Ask for confirmation from user if attempt is to run full sync. if ( empty ( $ skus ) && empty ( $ category_id ) ) { $ confirmation_text = dt ( 'I CONFIRM' ) ; $ input = $ this -> io ( ) -> ask ( dt ( 'Are you sure you want to import all products for @language language? If yes, type: "@confirmation"' , [ '@language' => $ langcode , '@confirmation' => $ confirmation_text , ] ) ) ; if ( $ input != $ confirmation_text ) { throw new UserAbortException ( dt ( 'Please be more attentive in using this command and prove you are not sleep working...' ) ) ; } } $ this -> output -> writeln ( dt ( 'Requesting all commerce products for selected language code...' ) ) ; $ this -> ingestApiWrapper -> productFullSync ( $ store_id , $ langcode , $ skus , $ category_id , $ page_size ) ; $ this -> output -> writeln ( dt ( 'Done.' ) ) ; }
Run a full synchronization of all commerce product records.

@param string $langcode
Sync products available in this langcode.
@param string $page_size
Number of items to be synced in one batch.
@param array $options
Command options.

@command acm_sku:sync-products

@option skus SKUs to import (like query).
@option category_id Magento category id to sync the products for.

@validate-module-enabled acm_sku

@aliases acsp,sync-commerce-products

@usage drush acsp en 50
Run a full product synchronization of all available products in store
linked to en and page size 50.
@usage drush acsp en 50 --skus=\'M-H3495 130 2  FW\',\'M-H3496 130 004FW\',\'M-H3496 130 005FW\''
Synchronize sku data for the skus M-H3495 130 2  FW, M-H3496 130 004FW
& M-H3496 130 005FW only in store linked to en and page size 50.
@usage drush acsp en 50 --category_id=1234
Synchronize sku data for the skus in category with id 1234 only in store
linked to en and page size 50.

@throws \Drush\Exceptions\UserAbortException
Run a full synchronization of all commerce product records .