/**
  * {@inheritdoc}
  */
 public function synchronizeVariationsPackages(ProductInterface $product, ArrayCollection $variations = null)
 {
     if (in_array('packages', $this->getVariationFields())) {
         return;
     }
     if (!$variations) {
         $variations = $product->getVariations();
     }
     $productPackages = $product->getPackages();
     /** @var ProductInterface $variation */
     foreach ($variations as $variation) {
         $variationPackages = $variation->getPackages();
         // browsing variation packages and remove excessing packages
         foreach ($variationPackages as $variationPackage) {
             if ($variationPackage && !$productPackages->contains($variationPackage)) {
                 $variation->removePackage($variationPackage);
             }
         }
         // browsing Product packages and add missing packages
         foreach ($productPackages as $productPackage) {
             if ($productPackage && !$variationPackages->contains($productPackage)) {
                 $package = clone $productPackage;
                 $variation->addPackage($package);
             }
         }
     }
 }