如何在Shopware插件中获取产品列表

时间:2017-11-21 00:14:41

标签: shopware

我很难获得要使用插件在目标网页中显示的产品列表。 文件在这方面发现不足。

我被困在这里:

$controller = $args->get('subject');
        $view = $controller->View();

        $view->addTemplateDir(
            __DIR__ . '/Views'
        );

1 个答案:

答案 0 :(得分:1)

也许这将帮助您解决问题

//get current article Id
$articleId = $view->sArticle['articleID'];
$query = $this->container->get('dbal_connection')->createQueryBuilder();
$query->select('s_articles.name')
  ->from('s_articles')
  ->where('s_articles.id = :id')
  ->setParameter('id', $articleId);
$single = $query->execute()->fetchColumn();
$view->assign('article_name', $single);
$view->assign('article_cat', '<a href="'.$view->sArticle['linkDetailsRewrited'].'">'.$view->sArticle['linkDetails'].'</a>' );


/**
 * Add template to the directory plugin
 */
$view->addTemplateDir($this->container->getParameter('gwen_cinema.plugin_dir') . '/Resources/Views');