modules/acm_promotion/src/AcmPromotionsManager.php
public function removeOrphanPromotionFromSku(SKU $sku, int $nid) {
    $promotion_detach_item[] = ['target_id' => $nid];
    $sku_promotions = $sku->get('field_acm_sku_promotions')->getValue();
    $sku_promotions = array_udiff($sku_promotions, $promotion_detach_item, function ($array1, $array2) {
      return $array1['target_id'] - $array2['target_id'];
    });
    $sku->get('field_acm_sku_promotions')->setValue($sku_promotions);
    $sku->save();
    // Update Sku Translations.
    $translation_languages = $sku->getTranslationLanguages(TRUE);
    if (!empty($translation_languages)) {
      foreach ($translation_languages as $langcode => $language) {
        $sku_entity_translation = $sku->getTranslation($langcode);
        $sku_entity_translation->get('field_acm_sku_promotions')->setValue($sku_promotions);
        $sku_entity_translation->save();
      }
    }
  }
public function removeOrphanPromotionFromSku(SKU $sku, int $nid) {
    $promotion_detach_item[] = ['target_id' => $nid];
    $sku_promotions = $sku->get('field_acm_sku_promotions')->getValue();
    $sku_promotions = array_udiff($sku_promotions, $promotion_detach_item, function ($array1, $array2) {
      return $array1['target_id'] - $array2['target_id'];
    });
    $sku->get('field_acm_sku_promotions')->setValue($sku_promotions);
    $sku->save();
    // Update Sku Translations.
    $translation_languages = $sku->getTranslationLanguages(TRUE);
    if (!empty($translation_languages)) {
      foreach ($translation_languages as $langcode => $language) {
        $sku_entity_translation = $sku->getTranslation($langcode);
        $sku_entity_translation->get('field_acm_sku_promotions')->setValue($sku_promotions);
        $sku_entity_translation->save();
      }
    }
  }
public function removeOrphanPromotionFromSku ( SKU $ sku , int $ nid ) { $ promotion_detach_item [ ] = [ 'target_id' => $ nid ] ; $ sku_promotions = $ sku -> get ( 'field_acm_sku_promotions' ) -> getValue ( ) ; $ sku_promotions = array_udiff ( $ sku_promotions , $ promotion_detach_item , function ( $ array1 , $ array2 ) { return $ array1 [ 'target_id' ] - $ array2 [ 'target_id' ] ; } ) ; $ sku -> get ( 'field_acm_sku_promotions' ) -> setValue ( $ sku_promotions ) ; $ sku -> save ( ) ; // Update Sku Translations. $ translation_languages = $ sku -> getTranslationLanguages ( TRUE ) ; if ( ! empty ( $ translation_languages ) ) { foreach ( $ translation_languages as $ langcode => $ language ) { $ sku_entity_translation = $ sku -> getTranslation ( $ langcode ) ; $ sku_entity_translation -> get ( 'field_acm_sku_promotions' ) -> setValue ( $ sku_promotions ) ; $ sku_entity_translation -> save ( ) ; } } }
Removes the given promotion from SKU entity.

@param \Drupal\acm_sku\Entity\SKU $sku
SKU Entity.
@param int $nid
Promotion node id.
Removes the given promotion from SKU entity .