File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3030use craft \elements \conditions \ElementConditionInterface ;
3131use craft \gql \types \DateTime ;
3232use craft \helpers \ArrayHelper ;
33+ use craft \helpers \Db ;
3334use craft \helpers \Html ;
3435use craft \models \FieldLayout ;
3536use Throwable ;
@@ -1006,6 +1007,19 @@ public function afterSave(bool $isNew): void
10061007 }
10071008
10081009 $ record ->save (false );
1010+
1011+ // Fallback updating of default variant data if the variant is being saved in isolation
1012+ if ($ this ->duplicateOf === null && $ this ->isDefault ) {
1013+ Db::update (Table::PRODUCTS , [
1014+ 'defaultVariantId ' => $ this ->id ,
1015+ 'defaultSku ' => $ this ->getSkuAsText (),
1016+ 'defaultPrice ' => $ this ->price ?? 0.0 ,
1017+ 'defaultHeight ' => $ this ->height ?? 0 ,
1018+ 'defaultLength ' => $ this ->length ?? 0 ,
1019+ 'defaultWidth ' => $ this ->width ?? 0 ,
1020+ 'defaultWeight ' => $ this ->weight ?? 0 ,
1021+ ], ['id ' => $ this ->productId ]);
1022+ }
10091023 }
10101024
10111025 parent ::afterSave ($ isNew );
You can’t perform that action at this time.
0 commit comments