modules/acm_promotion/src/AcmPromotionsManager.php
public function getSkusForPromotion(NodeInterface $promotion) {
    $query = $this->connection->select('acm_sku__field_acm_sku_promotions', 'fasp');
    if (\Drupal::entityTypeManager()->getDefinition('acm_sku')->isTranslatable()) {
      $query->join('acm_sku_field_data', 'asfd', 'asfd.id = fasp.entity_id');
    }
    else {
      $query->join('acm_sku', 'asfd', 'asfd.id = fasp.entity_id');
    }
    $query->condition('fasp.field_acm_sku_promotions_target_id', $promotion->id());
    $query->fields('asfd', ['id', 'sku']);
    $query->distinct();
    $skus = $query->execute()->fetchAllKeyed(0, 1);

    return $skus;
  }
public function getSkusForPromotion(NodeInterface $promotion) {
    $query = $this->connection->select('acm_sku__field_acm_sku_promotions', 'fasp');
    if (\Drupal::entityTypeManager()->getDefinition('acm_sku')->isTranslatable()) {
      $query->join('acm_sku_field_data', 'asfd', 'asfd.id = fasp.entity_id');
    }
    else {
      $query->join('acm_sku', 'asfd', 'asfd.id = fasp.entity_id');
    }
    $query->condition('fasp.field_acm_sku_promotions_target_id', $promotion->id());
    $query->fields('asfd', ['id', 'sku']);
    $query->distinct();
    $skus = $query->execute()->fetchAllKeyed(0, 1);

    return $skus;
  }
public function getSkusForPromotion ( NodeInterface $ promotion ) { $ query = $ this -> connection -> select ( 'acm_sku__field_acm_sku_promotions' , 'fasp' ) ; if ( \ Drupal :: entityTypeManager ( ) -> getDefinition ( 'acm_sku' ) -> isTranslatable ( ) ) { $ query -> join ( 'acm_sku_field_data' , 'asfd' , 'asfd.id = fasp.entity_id' ) ; } else { $ query -> join ( 'acm_sku' , 'asfd' , 'asfd.id = fasp.entity_id' ) ; } $ query -> condition ( 'fasp.field_acm_sku_promotions_target_id' , $ promotion -> id ( ) ) ; $ query -> fields ( 'asfd' , [ 'id' , 'sku' ] ) ; $ query -> distinct ( ) ; $ skus = $ query -> execute ( ) -> fetchAllKeyed ( 0 , 1 ) ; return $ skus ; }
Helper function to get skus attached with a promotion.

@param \Drupal\node\NodeInterface $promotion
Promotion node for which we need to find skus.

@return array
Array of sku objects attached with the promotion.
Helper function to get skus attached with a promotion .