initializeContext example


        $this->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        $modules = $this->get('modules');

        if (empty($this->get('session')->get('sUserId'))) {
            $modules->System()->sUSERGROUP = $shop->getCustomerGroup()->getKey();
            $modules->System()->sUSERGROUPDATA = $shop->getCustomerGroup()->toArray();
            $modules->System()->sCurrency = $shop->getCurrency()->toArray();
        }

        $this->get(ContextServiceInterface::class)->initializeContext();

        $shopContext = $this->get(ContextServiceInterface::class)->getShopContext();

        $modules->Basket()->sRefreshBasket();
        $modules->Admin()->sGetPremiumShippingcosts($shopContext->getCountry() ? $shopContext->getCountry()->jsonSerialize() : null);

        $amount = $modules->Basket()->sGetAmount();
        $this->get('session')->offsetSet('sBasketAmount', empty($amount) ? 0 : array_shift($amount));
    }
}
protected function refreshBasket()
    {
        $modules = $this->container->get('modules');
        $customerData = $modules->Admin()->sGetUserData();
        $session = $this->container->get('session');

        if (\is_array($customerData)) {
            $session->offsetSet('sCountry', (int) $customerData['additional']['countryShipping']['id']);
            $session->offsetSet('sArea', (int) $customerData['additional']['countryShipping']['areaID']);
        }

        $this->container->get(ContextServiceInterface::class)->initializeContext();

        $modules->Basket()->sRefreshBasket();
    }

    private function forwardDownloadError(int $errorCode): void
    {
        $this->View()->assign('sErrorCode', $errorCode);

        $this->forward('downloads');
    }

    
if ($this->sCurrency === false) {
            throw new RuntimeException('Currency could not be fetched correctly.');
        }
        $currency = Shopware()->Models()->getRepository(Currency::class)->find($this->sCurrency['id']);
        $shop->setCurrency($currency);
        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerShop($shop);

        if ($this->sCustomergroup !== false) {
            Shopware()->Container()->get('session')->offsetSet('sUserGroup', $this->sCustomergroup['groupkey']);
        }

        $this->contextService->initializeContext();

        $this->shop = $shop;

        $this->sSYSTEM->sCONFIG = $this->config;
    }

    /** * @return void */
    public function sInitSmarty()
    {
        
if ($this->config->get('migrateCartAfterLogin')) {
            Shopware()->Container()->get(CartPersistServiceInterface::class)->persist();
        }

        $shop = Shopware()->Shop();

        $this->sSYSTEM->sUSERGROUP = $shop->getCustomerGroup()->getKey();
        $this->sSYSTEM->sUSERGROUPDATA = $shop->getCustomerGroup()->toArray();
        $this->sSYSTEM->sCurrency = $shop->getCurrency()->toArray();

        $this->contextService->initializeContext();

        $this->csrfTokenValidator->clearExistingCookie();

        if (!$this->config->get('clearBasketAfterLogout')) {
            $this->moduleManager->Basket()->sRefreshBasket();

            $countries = $this->sGetCountryList();
            $country = reset($countries);
            if (!\is_array($country)) {
                $country = null;
            }

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