Ejemplo n.º 1
0
 /**
  * @param ProductInterface $product
  * @param array $options
  */
 private function createTranslations(ProductInterface $product, array $options)
 {
     foreach ($this->getLocales() as $localeCode) {
         $product->setCurrentLocale($localeCode);
         $product->setFallbackLocale($localeCode);
         $product->setName($options['name']);
         $product->setSlug($this->slugGenerator->generate($options['name']));
         $product->setShortDescription($options['short_description']);
         $product->setDescription($options['description']);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param ProductInterface $product
  * @param string $name
  * @param string $locale
  */
 private function addProductTranslation(ProductInterface $product, $name, $locale)
 {
     /** @var ProductTranslationInterface|TranslationInterface $translation */
     $translation = $this->productTranslationFactory->createNew();
     $translation->setLocale($locale);
     $translation->setName($name);
     $translation->setSlug($this->slugGenerator->generate($name));
     $product->addTranslation($translation);
 }
Ejemplo n.º 3
0
 /**
  * @param string $productName
  * @param int $price
  *
  * @return ProductInterface
  */
 private function createProduct($productName, $price = 0, $date = null)
 {
     /** @var ProductInterface $product */
     $product = $this->productFactory->createWithVariant();
     $product->setName($productName);
     $product->setCode(StringInflector::nameToUppercaseCode($productName));
     $product->setSlug($this->slugGenerator->generate($productName));
     $product->setCreatedAt(new \DateTime($date));
     /** @var ProductVariantInterface $productVariant */
     $productVariant = $this->defaultVariantResolver->getVariant($product);
     $productVariant->setPrice($price);
     $productVariant->setCode($product->getCode());
     return $product;
 }