小编Ste*_*mer的帖子

Shopware 6:店面编译中缺少node_modules

当我尝试编译shopware 6时

./bin/build-storefront.sh

我收到一条错误消息,提示 Chromium 下载无法完成。

npm ERR! code 1
npm ERR! path /home/username/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! ERROR: Failed to set up Chromium r950341! Set "PUPPETEER_SKIP_DOWNLOAD" env variable to skip download.
npm ERR! [Error: EINVAL: invalid argument, realpath '/home/username/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer/.local-chromium/linux-950341'] {
npm ERR!   errno: -22,
npm ERR!   code: 'EINVAL',
npm ERR!   syscall: 'realpath',
npm ERR!   path: '/home/username/vendor/shopware/storefront/Resources/app/storefront/node_modules/puppeteer/.local-chromium/linux-950341'
npm ERR! }

npm ERR! A complete log of this run can be found …
Run Code Online (Sandbox Code Playgroud)

chromium npm shopware puppeteer shopware6

2
推荐指数
1
解决办法
681
查看次数

如何在 Shopware 6 Storefront Controller 或 Subscriber 中检查用户是否已登录?

我正在寻找如何检查用户是否在 Shopware 6 店面中登录的正确方法。我正在编写一个插件(不是应用程序),并且想在控制器和/或订阅者中使用它。

我是不是该:

  1. 使用店面 API?(但是如何?走哪条路?)
  2. 使用默认的symfony方式?(isGranted) - 但有哪些角色?难道角色处理不一样吗?
  3. 使用一些内置功能,例如我可以通过依赖注入获取的特殊服务(但是是哪一个?)?

解决方案:

感谢@Uwe Kleinmann,我找到了一个解决方案,可以在这样的订阅者中工作:

public static function getSubscribedEvents()
{
  return [
    ProductPageLoadedEvent::class => 'onProductPageLoaded'
  ];
}
    
public function onProductPageLoaded(ProductPageLoadedEvent $event): void
{
  $saleschannelContext = $event->getSaleschannelContext();
  $customer = $saleschannelContext->getCustomer();

  if(NULL === $customer) {
    $customer = 'not-logged-in';
  }

  $event->getPage()->addExtension(
    'myextension', new ArrayStruct([
      'test' => $customer
    ])
  );
}
Run Code Online (Sandbox Code Playgroud)

authentication storefront shopware shopware6

1
推荐指数
1
解决办法
2228
查看次数