Пример #1
0
 /**
  * Generate articles from an array of hashes
  *
  * @param array $hashes
  * @param boolean $persist
  * @return \SplObjectStorage
  */
 public function generateArticlesFromHashes($hashes, $persist = false)
 {
     $articles = new \SplObjectStorage();
     foreach ($hashes as $hash) {
         $article = $this->articleHashingService->resolveHash($hash);
         $article->setPid(self::getCurrentPageId());
         $articles->attach($article);
         if ($persist && $article->_isNew()) {
             $product = $article->getProduct();
             $product->addArticle($article);
             $this->productRepository->update($product);
             $this->articleRepository->add($article);
         }
     }
     if ($persist) {
         $this->persistenceManager->persistAll();
     }
     return $articles;
 }