code: protected function updateVariants($item, $activeLanguage, $allIds, $baseAttributes = false)
      {
          foreach ($this->getAttributes() as $strAttributeId => $objAttribute) {
              // Skip unset attributes.
              if (!$item->isAttributeSet($objAttribute->getColName())) {
                  continue;
              }
  
              if (!$baseAttributes && $item->isVariant() && !($objAttribute->get('isvariant'))) {
                  // Skip base attribute.
                  continue;
              }
  
              if ($item->isVariantBase() && !($objAttribute->get('isvariant'))) {
                  // We have to override in variants.
                  $arrIds = $allIds;
              } else {
                  $arrIds = array($item->get('id'));
              }
              $this->saveAttribute($objAttribute, $arrIds, $item->get($strAttributeId), $activeLanguage);
          }
      }
docs: Update the variants with the value if needed.
  
  @param IItem  $item           The item to save.
  
  @param string $activeLanguage The language the values are in.
  
  @param int[]  $allIds         The ids of all variants.
  
  @param bool   $baseAttributes If also the base attributes get updated as well.
  
  @return void