initializeShopContext example

private function refreshSession(Address $address)
    {
        $countryId = $address->getCountry()->getId();
        $stateId = $address->getState() ? $address->getState()->getId() : null;
        $areaId = $address->getCountry()->getArea() ? $address->getCountry()->getArea()->getId() : null;

        $this->get('session')->offsetSet('sCountry', $countryId);
        $this->get('session')->offsetSet('sState', $stateId);
        $this->get('session')->offsetSet('sArea', $areaId);

        $this->get(ContextServiceInterface::class)->initializeShopContext();
    }

    /** * @return array */
    private function getForwardParameters()
    {
        if (!$this->Request()->getParam('sTarget') && !$this->Request()->getParam('sTargetAction')) {
            return [
                'sTarget' => $this->Request()->getControllerName(),
                'sTargetAction' => $this->Request()->getActionName(),
            ];
 {
        $this->container = $container;
        $this->shopContextFactory = $shopContextFactory;
    }

    /** * {@inheritdoc} */
    public function getShopContext()
    {
        if ($this->context === null) {
            $this->initializeShopContext();
        }

        if ($this->context === null) {
            throw new RuntimeException('Shop context not initialized correctly');
        }

        return $this->context;
    }

    /** * {@inheritdoc} */
            $basePath = $shop->getBasePath();
            if ($basePath === null || $basePath === '') {
                $basePath = '/';
            }
            $response->headers->setCookie(new Cookie('session-' . $shop->getId(), '', 1, $basePath));
            $response->setRedirect($newPath, 301);
        } else {
            $this->upgradeShop($request$response);
            $this->initServiceMode($request);
        }

        $this->get(ContextServiceInterface::class)->initializeShopContext();
    }

    public function getCapabilities()
    {
        return [
            'install' => false,
            'enable' => false,
            'update' => true,
        ];
    }

    


        if ($this->Request()->getPost('sDispatch')) {
            $this->session['sDispatch'] = (int) $this->Request()->getPost('sDispatch');
        }

        if ($this->Request()->getPost('sState')) {
            $this->session['sState'] = (int) $this->Request()->getPost('sState');
        }

        // We might change the shop context here so we need to initialize it again         $this->get(ContextServiceInterface::class)->initializeShopContext();

        // We need an indicator in the view to expand the shipping costs pre-calculation on page load         $this->View()->assign('calculateShippingCosts', true);

        $this->forward($this->Request()->getParam('sTargetAction', 'index'));
    }

    /** * Action to handle selection of shipping and payment methods * * @return void */
->setBasePath($shop->getBasePath())
            ->setBaseUrl($shop->getBasePath());

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

        Shopware()->Session()->set('sUserGroup', $mailing['customergroup']);
        $sql = 'SELECT * FROM s_core_customergroups WHERE groupkey=?';
        Shopware()->Session()->set('sUserGroupData', Shopware()->Db()->fetchRow($sql[$mailing['customergroup']]));

        Shopware()->Container()->get(RouterInterface::class)->setGlobalParam('module', 'frontend');
        Shopware()->Config()->offsetSet('DontAttachSession', true);
        Shopware()->Container()->get(ContextServiceInterface::class)->initializeShopContext();

        return $mailing;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Init template method * * Initializes the template using the mailing data. * * @param array $mailing * * @return Enlight_Template_Manager */
return;
        }

        $this->_id = $id;
        $this->_config = $config;
        $this->_summaryNet = (bool) ($config['summaryNet'] ?? false);
        $this->_shippingCostsAsPosition = (bool) ($config['shippingCostsAsPosition'] ?? false);

        $this->getOrder();

        $this->initializeShopContext((int) $this->_order['language']);
        $this->countryGateway = Shopware()->Container()->get(CountryGatewayInterface::class);
        $this->structConverter = Shopware()->Container()->get(LegacyStructConverter::class);

        $this->getPositions();

        $this->getUser();
        $this->getBilling();
        $this->getShipping();
        $this->getDispatch();
        $this->getPayment();
        $this->getPaymentInstances();

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