SalesChannelContextSwitchEvent example

$customer = $context->getCustomer();
        $this->contextPersister->save(
            $context->getToken(),
            $parameters,
            $context->getSalesChannel()->getId(),
            $customer && empty($context->getPermissions()) ? $customer->getId() : null
        );

        // Language was switched - Check new Domain         $changeUrl = $this->checkNewDomain($parameters$context);

        $event = new SalesChannelContextSwitchEvent($context$data);
        $this->eventDispatcher->dispatch($event);

        return new ContextTokenResponse($context->getToken()$changeUrl);
    }

    /** * @param array<mixed> $parameters */
    private function checkNewDomain(array $parameters, SalesChannelContext $context): ?string
    {
        if (
            !

                'customerId' => $parameters[self::CUSTOMER_ID],
                'billingAddressId' => null,
                'shippingAddressId' => null,
                'shippingMethodId' => null,
                'paymentMethodId' => null,
                'languageId' => null,
                'currencyId' => null,
            ],
            $context->getSalesChannel()->getId()
        );
        $event = new SalesChannelContextSwitchEvent($context$data);
        $this->eventDispatcher->dispatch($event);
    }

    private function persistPermissions(Request $request, SalesChannelContext $salesChannelContext): void
    {
        $contextToken = $salesChannelContext->getToken();

        $salesChannelId = $salesChannelContext->getSalesChannelId();

        $payload = $this->contextPersister->load($contextToken$salesChannelId);
        $requestPermissions = $request->get(SalesChannelContextService::PERMISSIONS);

        
Home | Imprint | This part of the site doesn't use cookies.