如何在Shopware Plugin中获取商品列表

How to get products list in Shopware Plugin

我很难使用插件获取要在着陆页中显示的产品列表。 文档在这方面发现不足。

我卡在这里了:

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

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

也许这会帮助您解决问题

//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');