diff --git a/src/elements/CommerceProduct.php b/src/elements/CommerceProduct.php index 4b5c00cb..dd58176c 100644 --- a/src/elements/CommerceProduct.php +++ b/src/elements/CommerceProduct.php @@ -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;