当我尝试编译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) 我正在寻找如何检查用户是否在 Shopware 6 店面中登录的正确方法。我正在编写一个插件(不是应用程序),并且想在控制器和/或订阅者中使用它。
我是不是该:
解决方案:
感谢@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)