Skip to content

Commit

Permalink
Fixes #3297
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Oct 17, 2023
1 parent 83f1eb4 commit 75f4a0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fixed a bug where Sale’s and Discount’s date audit columns weren’t populated after saving. ([#3298](https://github.com/craftcms/commerce/issues/3298))
- Fixed a bug where duplicate inactive users could be created when using the `commerce/upgrade` command. ([#3286](https://github.com/craftcms/commerce/issues/3286))
- The order param is now included when triggering the `craft\commerce\services\Purchasables::EVENT_PURCHASABLE_SHIPPABLE` event. ([#3279](https://github.com/craftcms/commerce/pull/3279))
- The auto-generated variant titles and SKUs are now generated when before saving a product in addition to before validation. ((#3297)[https://github.com/craftcms/commerce/pull/3297])

## 4.3.0 - 2023-09-13

Expand Down
9 changes: 8 additions & 1 deletion src/elements/Variant.php
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ public static function isLocalized(): bool
*/
public function beforeValidate(): bool
{
/** @var Product $product */
$product = $this->getProduct();

$this->updateTitle($product);
Expand Down Expand Up @@ -1159,8 +1160,14 @@ public function beforeValidate(): bool
*/
public function beforeSave(bool $isNew): bool
{
/** @var Product $product */
$product = $this->getProduct();

$this->updateTitle($product);
$this->updateSku($product);

// Set the field layout
$productType = $this->getProduct()->getType();
$productType = $product->getType();
$this->fieldLayoutId = $productType->variantFieldLayoutId;

return parent::beforeSave($isNew);
Expand Down

0 comments on commit 75f4a0a

Please sign in to comment.