Skip to content

Commit 77ac878

Browse files
committed
Fix product object default data not being updated on save
1 parent be0cbb8 commit 77ac878

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/elements/Product.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,15 @@ public function afterSave(bool $isNew): void
889889
$record->defaultWidth = $defaultVariant->width ?? 0;
890890
$record->defaultWeight = $defaultVariant->weight ?? 0;
891891

892+
// Make sure to update the object
893+
$this->defaultVariantId = $defaultVariant->id ?? null;
894+
$this->defaultSku = $defaultVariant->skuAsText ?? '';
895+
$this->defaultPrice = $defaultVariant->price ?? 0.0;
896+
$this->defaultHeight = $defaultVariant->height ?? 0;
897+
$this->defaultLength = $defaultVariant->length ?? 0;
898+
$this->defaultWidth = $defaultVariant->width ?? 0;
899+
$this->defaultWeight = $defaultVariant->weight ?? 0;
900+
892901
// We want to always have the same date as the element table, based on the logic for updating these in the element service i.e resaving
893902
$record->dateUpdated = $this->dateUpdated;
894903
$record->dateCreated = $this->dateCreated;

0 commit comments

Comments
 (0)