Skip to content

Commit

Permalink
Change the handling for variants.
Browse files Browse the repository at this point in the history
Change the save function. This should solve a problem where alias and combinedvalues fields didn't get the right values.
  • Loading branch information
stefanheimes committed Nov 4, 2015
1 parent 62b5de3 commit 2798cd6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/MetaModels/MetaModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,14 @@ protected function updateVariants($item, $activeLanguage, $allIds)
}
$this->saveAttribute($objAttribute, $arrIds, $item->get($strAttributeId), $activeLanguage);
}

// Run each id and trigger the model saved function.
foreach($allIds as $id){
$variantItem = $this->findById($id);
foreach ($this->getAttributes() as $strAttributeId => $objAttribute) {
$objAttribute->modelSaved($variantItem);
}
}
}

/**
Expand Down Expand Up @@ -1000,14 +1008,15 @@ public function saveItem($objItem)
}
}

$this->updateVariants($objItem, $strActiveLanguage, $arrAllIds);

// Tell all attributes that the model has been saved. Useful for alias fields, edit counters etc.
foreach ($this->getAttributes() as $objAttribute) {
if ($objItem->isAttributeSet($objAttribute->getColName())) {
$objAttribute->modelSaved($objItem);
}
}

// Update all variants.
$this->updateVariants($objItem, $strActiveLanguage, $arrAllIds);
}

/**
Expand Down

0 comments on commit 2798cd6

Please sign in to comment.