_storeCatLinks(item, result) {
    let index = 0;
    let length = result.length;

    switch (this.mode) {
      case ProductCategoriesModes.SEPARATE_ELASTICSEARCH: {
        for (let catLink of result) {
          // logger.debug('(' +index +'/' + length +  ') Storing categoryproduct link for ' + catLink.sku +' - ' + catLink.category_id);
          catLink.id = catLink.category_id * MAX_PRODUCTS_IN_CAT + index;

          index++;

          catLink = this.normalizeDocumentFormat(catLink);
        }

        logger.debug('Performing bulk update...');
        this.db.updateDocumentBulk('productcategories', result); // TODO: add support for BULK operations and DELETE 
      }

      case ProductCategoriesModes.UPDATE_CATEGORY: {
        // TODO: update products to set valid category
        item.products = result;
        this.db.updateDocument('category', item);
        logger.debug(`Updating category object for ${item.id}`);
      }

      default: { // update in redis = ProductCategoriesModes.SEPARATE_REDIS
        logger.debug(`Storing category assigments in REDIS cache for ${item.id}`);

        for (let catLink of result) {
          const key = util.format(CacheKeys.CACHE_KEY_PRODUCT_CATEGORIES_TEMPORARY, catLink.sku); // store under SKU of the product the categories assigned

          this.cache.sadd(key, catLink.category_id); // add categories to sets
          this._productHisto.add(catLink.sku);
        }
      }
    }

    logger.info(`The task count still is = ${this.tasks_count}`);
  }
/**
   * Process category link product/category
   * @param {Object} result 
   */
Process category link product/category
@param {Object} result
Process category link product / category @param { Object } result
_storeCatLinks(item, result) {
    let index = 0;
    let length = result.length;
    switch (this.mode) {
      case ProductCategoriesModes.SEPARATE_ELASTICSEARCH: {
        for (let catLink of result) {
          catLink.id = catLink.category_id * MAX_PRODUCTS_IN_CAT + index;
          index++;
          catLink = this.normalizeDocumentFormat(catLink);
        }
        logger.debug('Performing bulk update...');
        this.db.updateDocumentBulk('productcategories', result); 
      }
      case ProductCategoriesModes.UPDATE_CATEGORY: {
        item.products = result;
        this.db.updateDocument('category', item);
        logger.debug(`Updating category object for ${item.id}`);
      }
      default: { 
        logger.debug(`Storing category assigments in REDIS cache for ${item.id}`);
        for (let catLink of result) {
          const key = util.format(CacheKeys.CACHE_KEY_PRODUCT_CATEGORIES_TEMPORARY, catLink.sku); 
          this.cache.sadd(key, catLink.category_id); 
          this._productHisto.add(catLink.sku);
        }
      }
    }
    logger.info(`The task count still is = ${this.tasks_count}`);
  }
_storeCatLinks ( item , result ) { let index = 0 ; let length = result . length ; switch ( this . mode ) { case ProductCategoriesModes . SEPARATE_ELASTICSEARCH : { for ( let catLink of result ) { catLink . id = catLink . category_id * MAX_PRODUCTS_IN_CAT + index ; index ++ ; catLink = this . normalizeDocumentFormat ( catLink ) ; } logger . debug ( 'Performing bulk update...' ) ; this . db . updateDocumentBulk ( 'productcategories' , result ) ; } case ProductCategoriesModes . UPDATE_CATEGORY : { item . products = result ; this . db . updateDocument ( 'category' , item ) ; logger . debug ( ` ${ item . id } ` ) ; } default : { logger . debug ( ` ${ item . id } ` ) ; for ( let catLink of result ) { const key = util . format ( CacheKeys . CACHE_KEY_PRODUCT_CATEGORIES_TEMPORARY , catLink . sku ) ; this . cache . sadd ( key , catLink . category_id ) ; this . _productHisto . add ( catLink . sku ) ; } } } logger . info ( ` ${ this . tasks_count } ` ) ; }
Process category link product/category
 @param {Object} result
Process category link product / category @param { Object } result
// logger.debug('(' +index +'/' + length +  ') Storing categoryproduct link for ' + catLink.sku +' - ' + catLink.category_id); // TODO: add support for BULK operations and DELETE  // TODO: update products to set valid category // update in redis = ProductCategoriesModes.SEPARATE_REDIS // store under SKU of the product the categories assigned // add categories to sets