Skip to content

Commit

Permalink
propagate variants too & ensure they get updated with new content
Browse files Browse the repository at this point in the history
  • Loading branch information
i-just committed Oct 15, 2024
1 parent 2544dd7 commit d6b91d4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/elements/CommerceProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,18 @@ public function checkPropagation($existingElement, array $feed)
$existingElement->setEnabledForSite($siteStatuses);

// Propagate the product, and swap it with the propagated copy
return Craft::$app->getElements()->propagateElement($existingElement, $targetSiteId);
$propagatedElement = Craft::$app->getElements()->propagateElement($existingElement, $targetSiteId);

// we need this so that the variants get propagated too
$propagatedElement->setVariants($existingElement->getVariants());
$propagatedElement->newSiteIds = [$targetSiteId];
$propagatedElement->afterPropagate(false);

// we're done propagating now
$propagatedElement->propagating = false;
$propagatedElement->propagatingFrom = null;

return $propagatedElement;
}

return $existingElement;
Expand Down

0 comments on commit d6b91d4

Please sign in to comment.