/**
  * {@inheritdoc}
  */
 public function generate(ProductInterface $product)
 {
     Assert::true($product->hasOptions(), 'Cannot generate variants for an object without options.');
     $optionSet = [];
     $optionMap = [];
     foreach ($product->getOptions() as $key => $option) {
         foreach ($option->getValues() as $value) {
             $optionSet[$key][] = $value->getId();
             $optionMap[$value->getId()] = $value;
         }
     }
     $permutations = $this->setBuilder->build($optionSet);
     foreach ($permutations as $permutation) {
         $variant = $this->createVariant($product, $optionMap, $permutation);
         $product->addVariant($variant);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function generate(ProductInterface $variable)
 {
     if (!$variable->hasOptions()) {
         throw new \InvalidArgumentException('Cannot generate variants for an object without options.');
     }
     $optionSet = [];
     $optionMap = [];
     foreach ($variable->getOptions() as $key => $option) {
         foreach ($option->getValues() as $value) {
             $optionSet[$key][] = $value->getId();
             $optionMap[$value->getId()] = $value;
         }
     }
     $permutations = $this->setBuilder->build($optionSet);
     foreach ($permutations as $permutation) {
         $variant = $this->createVariant($variable, $optionMap, $permutation);
         $variable->addVariant($variant);
     }
 }