Ejemplo n.º 1
0
 /**
  * Internal helper function to duplicate the article link configuration from the passed article
  * to the new article.
  * @param $articleId
  * @param $newArticleId
  */
 protected function duplicateArticleLinks($articleId, $newArticleId)
 {
     $article = Shopware()->Models()->find('Shopware\\Models\\Article\\Article', $newArticleId);
     $builder = Shopware()->Models()->createQueryBuilder();
     $links = $builder->select(array('links', 'attribute'))->from('Shopware\\Models\\Article\\Link', 'links')->leftJoin('links.attribute', 'attribute')->where('links.articleId = ?1')->setParameter(1, $articleId)->getQuery()->getArrayResult();
     foreach ($links as $data) {
         $link = new \Shopware\Models\Article\Link();
         $link->fromArray($data);
         $link->setArticle($article);
         Shopware()->Models()->persist($link);
     }
     Shopware()->Models()->flush();
 }