Skip to content

Commit 5b6bd34

Browse files
committed
Merge branch '5.x' into 5.6
# Conflicts: # src/elements/Product.php
2 parents 7f55b0a + 278ed8e commit 5b6bd34

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/elements/Product.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,13 +1336,13 @@ public function getVariantManager(): NestedElementManager
13361336
if (!isset($this->_variantManager)) {
13371337
$this->_variantManager = new NestedElementManager(
13381338
Variant::class,
1339-
/** @phpstan-ignore-next-line */
1340-
fn(Product $product) => self::createVariantQuery($product),
1339+
// @phpstan-ignore argument.type (will always be a Product)
1340+
fn(ElementInterface $product): VariantQuery => self::createVariantQuery($product),
13411341
[
1342-
'attribute' => 'allVariants',
1342+
'attribute' => 'variants',
13431343
'propagationMethod' => $this->getType()->propagationMethod,
1344-
'valueSetter' => fn($variants) => $this->setVariants($variants),
13451344
'valueGetter' => fn() => $this->getVariants(true),
1345+
'valueSetter' => fn($variants) => $this->setVariants($variants),
13461346
],
13471347
);
13481348
}
@@ -1650,10 +1650,14 @@ public function afterSave(bool $isNew): void
16501650
$record->dateUpdated = $this->dateUpdated;
16511651
$record->dateCreated = $this->dateCreated;
16521652

1653+
// Capture the dirty attributes from the record
1654+
$dirtyAttributes = array_keys($record->getDirtyAttributes());
16531655
$record->save(false);
16541656

16551657
$this->id = $record->id;
16561658

1659+
$this->setDirtyAttributes($dirtyAttributes);
1660+
16571661
if ($this->getIsCanonical() &&
16581662
isset($this->typeId) &&
16591663
$productType->isStructure
@@ -1843,15 +1847,15 @@ function() {
18431847
/**
18441848
* @inheritdoc
18451849
*/
1846-
public function setAttributes($values, $safeOnly = true): void
1850+
public function setAttributesFromRequest(array $values): void
18471851
{
18481852
// this is needed for Craft.NestedElementManager::markAsDirty()
18491853
if (isset($values['variants']) && $values['variants'] === '*') {
18501854
$this->setDirtyAttributes(['variants']);
18511855
unset($values['variants']);
18521856
}
18531857

1854-
parent::setAttributes($values, $safeOnly);
1858+
parent::setAttributesFromRequest($values);
18551859
}
18561860

18571861
/**

0 commit comments

Comments
 (0)