Skip to content

Commit 4eda53b

Browse files
committed
Fixed a bug where variants would not save
Fixed a bug where the nested variant element manager used different attribute names (`allVariants` & `variants`) across different versions of 5.x Setting all as dirty ensures it saves the variants in the nested element manager regardless of the attribute name used.
1 parent 824a416 commit 4eda53b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/elements/CommerceProduct.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public function save($element, $settings): bool
275275
$this->beforeSave($element, $settings);
276276

277277
if ($this->element->getIsDraft()) {
278-
$this->element->setDirtyAttributes(['variants']);
278+
$this->element->markAsDirty();
279279
$this->element = Craft::$app->getDrafts()->applyDraft($this->element);
280280
$this->element->propagateAll = true;
281281
}
@@ -548,7 +548,7 @@ private function _parseVariants($event): void
548548
// Create a new variant, or find an existing one to edit
549549
if (!isset($variants[$sku])) {
550550
$variants[$sku] = new VariantElement();
551-
$variants[$sku]->product = $element;
551+
$variants[$sku]->setOwner($element);
552552
}
553553

554554
// We are going to handle stock after the product and variants save

0 commit comments

Comments
 (0)