getMain example

 {
        $this->db = $db ?: Shopware()->Db();
        $this->eventManager = $eventManager ?: Shopware()->Events();
        $this->config = $config ?: Shopware()->Config();
        $this->session = $session ?: Shopware()->Session();
        $this->front = $front ?: Shopware()->Front();
        $this->passwordEncoder = $passwordEncoder ?: Shopware()->PasswordEncoder();
        $this->snippetManager = $snippetManager ?: Shopware()->Snippets();
        $this->moduleManager = $moduleManager ?: Shopware()->Modules();
        $this->sSYSTEM = $systemModule ?: Shopware()->System();

        $mainShop = Shopware()->Shop()->getMain() !== null ? Shopware()->Shop()->getMain() : Shopware()->Shop();
        $this->scopedRegistration = $mainShop->getCustomerScope();

        $this->contextService = $contextService ?: Shopware()->Container()->get(ContextServiceInterface::class);
        $this->emailValidator = $emailValidator ?: Shopware()->Container()->get(EmailValidator::class);
        $this->subshopId = $this->contextService->getShopContext()->getShop()->getParentId();
        $this->attributeLoader = Shopware()->Container()->get(DataLoader::class);
        $this->translationComponent = $translationComponent ?: Shopware()->Container()->get(\Shopware_Components_Translation::class);
        $this->connection = $connection ?: Shopware()->Container()->get(Connection::class);
        $this->optInLoginService = $optInLoginService ?: Shopware()->Container()->get(OptInLoginService::class);
        $this->conditionalLineItemService = Shopware()->Container()->get(ConditionalLineItemServiceInterface::class);
        $this->cartOrderNumberProvider = Shopware()->Container()->get(CartOrderNumberProviderInterface::class);
        

    protected function initExtends()
    {
        $extends = [];
        $shop = $this->shop;
        $locale = $this->locale;
        if (!$locale instanceof Locale) {
            throw new ShopLocaleNotSetException();
        }

        $main = $shop !== null ? $shop->getMain() : null;
        if ($main !== null && $main->getId() === 1) {
            $main = null;
        }

        // fallback to parent shop, current locale         if ($main !== null && $main->getId() !== 1) {
            $extends[] = [
                $main->getId(),
                $locale->getId(),
            ];
        }

        
/** * Helper function to build a unique file name. * * @param string $timestamp * @param string $suffix * * @return string */
    public function buildTimestampName($timestamp, Shop\Shop $shop$suffix)
    {
        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        $filename = $timestamp . '_' . md5($timestamp . $shop->getTemplate()->getId() . $shop->getId() . $this->release->getRevision());

        return $filename . '.' . $suffix;
    }

    /** * @return string */
    

    public function setPriceGroup($priceGroup)
    {
        $this->priceGroup = $priceGroup;
    }

    public function setLanguageSubShop(Shop $languageSubShop)
    {
        $this->languageSubShop = $languageSubShop;

        $subShop = $languageSubShop->getMain() ?: $languageSubShop;
        $this->setShop($subShop);
    }

    /** * @return Shop */
    public function getLanguageSubShop()
    {
        return $this->languageSubShop;
    }

    

    protected $customerScope;

    /** * @return Shop */
    public static function createFromShopEntity(ShopEntity $shop)
    {
        $struct = new self();
        $struct->setId($shop->getId());
        $struct->setParentId($shop->getMain() ? $shop->getMain()->getId() : $shop->getId());

        $struct->setCustomerScope($shop->getMain() ? $shop->getMain()->getCustomerScope() : $shop->getCustomerScope());
        $struct->setIsDefault($shop->getDefault());
        $struct->setName($shop->getName());
        $struct->setHost($shop->getHost());
        $struct->setPath($shop->getBasePath());
        $struct->setUrl($shop->getBaseUrl());
        $struct->setSecure($shop->getSecure());
        if ($shop->getCategory()) {
            $struct->setCategory(
                Category::createFromCategoryEntity($shop->getCategory())
            );
return $this->getQueryBuilder()
            ->where('shop.active = 1');
    }

    /** * @return DetachedShop */
    protected function fixActive(Shop $shop)
    {
        $shop = DetachedShop::createFromShop($shop);

        $main = $shop->getMain();
        if ($main !== null) {
            $main = DetachedShop::createFromShop($main);
            $shop->setHost($main->getHost());
            $shop->setSecure($main->getSecure());
            $shop->setBasePath($shop->getBasePath() ?: $main->getBasePath());
            $shop->setTemplate($main->getTemplate());
            $shop->setCurrencies($main->getCurrencies());
            $shop->setChildren($main->getChildren());
            $shop->setCustomerScope($main->getCustomerScope());
        }

        
$image,
                    $media
                );

                $image->setPosition($position);
                ++$position;
            }

            $image->fromArray($imageData);

            // if image is set as main set other images to secondary             if ((int) $image->getMain() === 1) {
                foreach ($images as $otherImage) {
                    // Only update existing images which are not the current processed image.                     // Otherwise, the main flag won't be changed.                     if ($otherImage->getId() !== $image->getId()) {
                        $otherImage->setMain(2);
                    }
                }
            }

            if (isset($imageData['options'])) {
                $this->createImageMappings($image$product$imageData['options']);
            }
if ($this->getShop() !== null) {
            $defaultContext = [
                'sConfig' => $config,
                'sShop' => $config->get('shopName'),
                'sShopURL' => ($this->getShop()->getSecure() ? 'https://' : 'http://') . $this->getShop()->getHost() . $this->getShop()->getBaseUrl(),
            ];

            // Add theme to the context if given shop (or its main shop) has a template.             $theme = null;
            if ($this->getShop()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getTemplate()$this->getShop(), false);
            } elseif ($this->getShop()->getMain() && $this->getShop()->getMain()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getMain()->getTemplate()$this->getShop(), false);
            }

            if ($theme) {
                $keys = $eventManager->filter(
                    'TemplateMail_CreateMail_Available_Theme_Config',
                    $this->themeVariables,
                    ['theme' => $theme]
                );

                $theme = array_intersect_key($theme$keys);
                
            session_id('');
        }

        $sessionOptions = $container->getParameter('shopware.session');

        if (!\is_array($sessionOptions)) {
            throw new RuntimeException('Parameter shopware.session has to be an array');
        }

        /** @var \Shopware\Models\Shop\Shop $shop */
        $shop = $container->get('shop');
        $mainShop = $shop->getMain() ?: $shop;

        $name = 'session-' . $shop->getId();

        if ($container->get(Shopware_Components_Config::class)->get('shareSessionBetweenLanguageShops')) {
            $name = 'session-' . $mainShop->getId();
        }

        $sessionOptions['name'] = $name;

        if ($mainShop->getSecure()) {
            $sessionOptions['cookie_secure'] = true;
        }
return ($request->isSecure() ? 'https' : 'http') . '://' . $request->getHttpHost() . $request->getBasePath() . '/' . $this->createPublicPath();
        }

        if ($this->container->initialized('shop')) {
            /** @var Shop $shop */
            $shop = $this->container->get('shop');
        } else {
            /** @var Shop $shop */
            $shop = $this->container->get(\Shopware\Components\Model\ModelManager::class)->getRepository(Shop::class)->getActiveDefault();
        }

        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        if ($shop->getSecure()) {
            return 'https://' . $shop->getHost() . $shop->getBasePath() . '/' . $this->createPublicPath();
        }

        return 'http://' . $shop->getHost() . $shop->getBasePath() . '/' . $this->createPublicPath();
    }

    /** * @return string */
$response->setRedirect($redirectUrl);

                if ($newShop->getBasePath()) {
                    $cookiePath = $newShop->getBasePath();
                } else {
                    $cookiePath = $request->getBasePath();
                }

                $cookiePath = rtrim((string) $cookiePath, '/') . '/';

                // If shop is main, remove the cookie                 $cookieTime = $newShop->getMain() === null ? time() - 3600 : 0;

                $response->headers->setCookie(new Cookie($cookieKey$cookieValue$cookieTime$cookiePath, null, $request->isSecure()));

                $this->refreshCart($newShop);

                return;
            }
        }

        // currency switch         if ($cookieKey === 'currency') {
            
if ($request && $request->getHttpHost()) {
            return ($request->isSecure() ? 'https' : 'http') . '://' . $request->getHttpHost() . $request->getBasePath() . '/';
        }

        if ($this->container->initialized('shop')) {
            $shop = $this->container->get('shop');
        } else {
            $shop = $this->container->get(ModelManager::class)->getRepository(Shop::class)->getActiveDefault();
        }

        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        if ($shop->getSecure()) {
            return 'https://' . $shop->getHost() . $shop->getBasePath() . '/';
        }

        return 'http://' . $shop->getHost() . $shop->getBasePath() . '/';
    }

    /** * Used as internal check for the liveMigration config flag. * * @param string $path */
AbstractQuery::HYDRATE_OBJECT
        )[0];

        if (!$shop) {
            $this->View()->assign([
                'success' => false,
            ]);

            return;
        }

        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        try {
            /** @var Compiler $compiler */
            $compiler = $this->container->get('theme_compiler');
            $compiler->compileJavascript('new', $shop->getTemplate()$shop);
            $compiler->compileLess('new', $shop->getTemplate()$shop);
        } catch (Exception $e) {
            $this->View()->assign(['success' => false, 'message' => $e->getMessage()]);

            
/** * Helper function which compiles a shop with new theme. * The function is called when the template cache is cleared. * * @throws Exception * * @return void */
    public function compile(Shop $shop)
    {
        if ($shop->getMain()) {
            $shop = $shop->getMain();
        }

        $old = $this->getThemeTimestamp($shop);
        $timestamp = time();

        $this->compileLess($timestamp$shop->getTemplate()$shop);
        $this->compileJavascript($timestamp$shop->getTemplate()$shop);

        $this->createThemeTimestamp($shop$timestamp);
        $this->clearThemeCache($shop$old);
    }
$this->sBasketData[CartKey::AMOUNT_NET_NUMERIC] = round($this->sBasketData[CartKey::AMOUNT_NET_NUMERIC], 2);

        if (empty($this->sBasketData[CheckoutKey::CURRENCY_NAME])) {
            $this->sBasketData[CheckoutKey::CURRENCY_NAME] = 'EUR';
        }
        if (empty($this->sBasketData[CheckoutKey::CURRENCY_FACTOR])) {
            $this->sBasketData[CheckoutKey::CURRENCY_FACTOR] = '1';
        }

        $shop = Shopware()->Shop();
        $mainShop = $shop->getMain() !== null ? $shop->getMain() : $shop;

        $taxfree = '0';
        if (!empty($this->sNet)) {
            // Complete net delivery             $net = '1';
            $this->sBasketData[CartKey::AMOUNT_WITH_TAX_NUMERIC] = $this->sBasketData[CartKey::AMOUNT_NET_NUMERIC];
            $this->sShippingcostsNumeric = $this->sShippingcostsNumericNet;
            $taxfree = '1';
        }
        if (empty($this->sBasketData[CartKey::AMOUNT_WITH_TAX_NUMERIC])) {
            $this->sBasketData[CartKey::AMOUNT_WITH_TAX_NUMERIC] = '0';
        }
Home | Imprint | This part of the site doesn't use cookies.