modules/acm_promotion/src/AcmPromotionsManager.php
public function syncPromotions($types = ['category', 'cart']) {
    $types = is_array($types) ? $types : [$types];
    $ids = [];
    $fetched_promotions = [];

    foreach ($types as $type) {
      $promotions = $this->apiWrapper->getPromotions($type);

      foreach ($promotions as $key => $promotion) {
        // Add type to $promotion array, to be saved later.
        $promotion['promotion_type'] = $type;
        $fetched_promotions[] = $promotion;
        $ids[] = $promotion['rule_id'];
      }
    }

    if (!empty($fetched_promotions)) {
      $this->processPromotions($fetched_promotions);
    }

    // Delete promotions, which are not part of API response.
    if (!empty($ids)) {
      $this->deletePromotions($types, $ids);
    }
  }
public function syncPromotions($types = ['category', 'cart']) {
    $types = is_array($types) ? $types : [$types];
    $ids = [];
    $fetched_promotions = [];

    foreach ($types as $type) {
      $promotions = $this->apiWrapper->getPromotions($type);

      foreach ($promotions as $key => $promotion) {
        // Add type to $promotion array, to be saved later.
        $promotion['promotion_type'] = $type;
        $fetched_promotions[] = $promotion;
        $ids[] = $promotion['rule_id'];
      }
    }

    if (!empty($fetched_promotions)) {
      $this->processPromotions($fetched_promotions);
    }

    // Delete promotions, which are not part of API response.
    if (!empty($ids)) {
      $this->deletePromotions($types, $ids);
    }
  }
public function syncPromotions ( $ types = [ 'category' , 'cart' ] ) { $ types = is_array ( $ types ) ? $ types : [ $ types ] ; $ ids = [ ] ; $ fetched_promotions = [ ] ; foreach ( $ types as $ type ) { $ promotions = $ this -> apiWrapper -> getPromotions ( $ type ) ; foreach ( $ promotions as $ key => $ promotion ) { // Add type to $promotion array, to be saved later. $ promotion [ 'promotion_type' ] = $ type ; $ fetched_promotions [ ] = $ promotion ; $ ids [ ] = $ promotion [ 'rule_id' ] ; } } if ( ! empty ( $ fetched_promotions ) ) { $ this -> processPromotions ( $ fetched_promotions ) ; } // Delete promotions, which are not part of API response. if ( ! empty ( $ ids ) ) { $ this -> deletePromotions ( $ types , $ ids ) ; } }
Synchronize promotions through the API.

@param mixed $types
The type of promotion to synchronize.
Synchronize promotions through the API .