MetaModels\MetaModel::updateVariants PHP Method

updateVariants() protected method

Update the variants with the value if needed.
protected updateVariants ( metamodels\IItem $item, string $activeLanguage, int[] $allIds, boolean $baseAttributes = false ) : void
$item metamodels\IItem The item to save.
$activeLanguage string The language the values are in.
$allIds int[] The ids of all variants.
$baseAttributes boolean If also the base attributes get updated as well.
return void
    protected function updateVariants($item, $activeLanguage, $allIds, $baseAttributes = false)
    {
        foreach ($this->getAttributes() as $strAttributeId => $objAttribute) {
            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);
        }
    }