Shop example


    public function __construct()
    {
        $config = Shopware()->Container()->get(Shopware_Components_Config::class);

        $this->db = Shopware()->Container()->get('db');
        $this->manager = Shopware()->Container()->get(ModelManager::class);
        $this->repository = $this->manager->getRepository(CategoryModel::class);
        $this->baseUrl = $config->get('baseFile') . '?sViewport=cat&sCategory=';
        $this->blogBaseUrl = $config->get('baseFile') . '?sViewport=blog&sCategory=';
        $this->baseId = (int) Shopware()->Shop()->get('parentID');
        $this->customerGroupId = (int) (Shopware()->Modules()->System()->sUSERGROUPDATA['id'] ?? 0);
        $this->connection = Shopware()->Container()->get(Connection::class);
        $this->categoryService = Shopware()->Container()->get(CategoryServiceInterface::class);
        $this->contextService = Shopware()->Container()->get(ContextServiceInterface::class);
    }

    /** * Returns the category tree from the root until the category * with the provided id. Also loads siblings for elements in the * category path. * * @param int $id Id of the category to load * * @return array Tree of categories */
$this->template->registerPlugin(
                Smarty::PLUGIN_FUNCTION,
                'createSupplierPath',
                [$this, 'createSupplierPath']
            );
        }

        $this->data = $this->template->createData();

        $this->data->assign('sConfig', $this->config);
        $this->data->assign('sRouter', $this);
        $this->data->assign('sCategoryStart', Shopware()->Shop()->getCategory()->getId());
    }

    /** * Main method for re-creating the rewrite table. Triggers all other (more specific) methods * * @param string $lastUpdate * * @throws SmartyException * @throws \Enlight_Event_Exception * @throws Zend_Db_Adapter_Exception * @throws Exception * * @return string */


        $this->View()->assign('partnerStatisticToDate', $toDate->format('Y-m-d'));
        $this->View()->assign('partnerStatisticFromDate', $fromDate->format('Y-m-d'));

        // To get the right value cause 2012-02-02 is smaller than 2012-02-02 15:33:12         $toDate = $toDate->add(new DateInterval('P1D'));

        $repository = $this->get('models')->getRepository(Partner::class);

        // Get the information of the partner chart         $customerCurrencyFactor = Shopware()->Shop()->getCurrency()->getFactor();

        $dataQuery = $repository->getStatisticChartQuery($partnerId$fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrderChartData', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, false, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrders', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, true, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sTotalPartnerAmount', $dataQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY));
    }

    
$system->_SESSION = Shopware()->Session();
            $system->sSESSION_ID = Shopware()->Session()->get('sessionId');
            if ($request !== null && Shopware()->Session()->get('Bot') === null) {
                /** @var Shopware_Plugins_Frontend_Statistics_Bootstrap $plugin */
                $plugin = Shopware()->Plugins()->Frontend()->Statistics();
                Shopware()->Session()->set('Bot', $plugin->checkIsBot($request->getHeader('USER_AGENT') ?: ''));
            }
            $system->sBotSession = Shopware()->Session()->get('Bot');
        }

        if (Shopware()->Container()->initialized('shop')) {
            $shop = Shopware()->Shop();
            $system->sCurrency = $shop->getCurrency()->toArray();

            $system->sUSERGROUP = $shop->getCustomerGroup()->getKey();
            $system->sUSERGROUPDATA = $shop->getCustomerGroup()->toArray();
            $config->offsetSet('defaultCustomerGroup', $system->sUSERGROUP);

            $config['sCURRENCY'] = $system->sCurrency['currency'];
            $config['sCURRENCYHTML'] = $system->sCurrency['symbol'];
        }

        if (Shopware()->Container()->initialized('session')) {
            

    public function flagPaymentBlocked()
    {
        $this->View()->assign('paymentBlocked', true);
    }

    /** * Save basket to session */
    public function postDispatch()
    {
        $this->session->set('sBasketCurrency', Shopware()->Shop()->getCurrency()->getId());
        $this->session->set('sBasketQuantity', $this->basket->sCountBasket());
        $amount = $this->basket->sGetAmount();
        $this->session->set('sBasketAmount', empty($amount) ? 0 : array_shift($amount));

        if (($messageType = $this->Request()->query->get('removeMessage')) && $messageType === 'voucher') {
            $this->session->offsetUnset('sBasketVoucherRemovedInCart');
        }

        if ($this->session->offsetExists('sBasketVoucherRemovedInCart')) {
            $this->View()->assign('sBasketVoucherRemovedInCart', true);
        }
    }

        $this->View()->assign('sGroup', $this->Request()->getParam('group'));
        $plugin = Shopware()->Plugins()->Core()->ControllerBase();
        $this->View()->assign('sMenu', $plugin->getMenu());
    }

    /** * Get shop menu */
    public function shopMenuAction(): void
    {
        $shop = Shopware()->Shop();
        $main = DetachedShop::createFromShop($shop->getMain() ?? $shop);

        $this->View()->assign('shop', $shop);
        if (!$this->Request()->getParam('hideCurrency', false)) {
            $this->View()->assign('currencies', $shop->getCurrencies());
        }
        $languages = $shop->getChildren()->toArray();
        foreach ($languages as $languageKey => $language) {
            $language = DetachedShop::createFromShop($language);
            if (!$language->getActive()) {
                unset($languages[$languageKey]);
            }
if ($request->get('action') === 'manufacturer' && $request->get('controller') === 'listing') {
            $alias = $mapper->getQueryAliases();

            if (\array_key_exists('sSupplier', $alias) && ($index = array_search($alias['sSupplier']$queryBlacklist, true))) {
                unset($queryBlacklist[$index]);
            }

            if ($index = array_search('sSupplier', $queryBlacklist, true)) {
                unset($queryBlacklist[$index]);
            }

            if ($request->getQuery('sCategory') !== Shopware()->Shop()->getCategory()->getId()) {
                $queryBlacklist[] = 'sCategory';
                if (\array_key_exists('sCategory', $alias)) {
                    $queryBlacklist[] = $alias['sCategory'];
                }
            }
        }

        if (\in_array($controller$controllerBlacklist, true)) {
            $metaRobots = 'noindex,follow';
        } elseif (!empty($queryBlacklist)) {
            foreach ($queryBlacklist as $queryKey) {
                
$fallbackId = null;
        $translations = null;

        $sql = 'SELECT * FROM s_cms_static WHERE id = :pageId and active = 1';
        $params = ['pageId' => $staticId];

        if ($shopId) {
            $sql .= ' AND (shop_ids IS NULL OR shop_ids LIKE :shopId)';
            $params['shopId'] = '%|' . $shopId . '|%';

            if (Shopware()->Shop()->getFallback()) {
                $fallbackId = Shopware()->Shop()->getFallback()->getId();
            }

            $translations = $this->translationComponent->readWithFallback($shopId$fallbackId, 'page', $staticId);
        }

        // Load static page data from database         $staticPage = $this->db->fetchRow(
            $sql,
            $params
        );
        
'sNotify' => '1',
                        'action' => 'notifyConfirm',
                        'number' => $notifyOrderNumber,
                    ]);

                    /** @var Shopware_Components_Modules $modules */
                    $modules = $this->get('modules');

                    $name = $modules->Articles()->sGetArticleNameByOrderNumber($notifyOrderNumber);

                    $basePath = $action->Front()->ensureRouter()->assemble(['sViewport' => 'index']);
                    $modules->System()->_POST['sLanguage'] = Shopware()->Shop()->getId();
                    $modules->System()->_POST['sShopPath'] = $basePath . Shopware()->Config()->get('sBASEFILE');

                    $sql = ' INSERT INTO s_core_optin (datum, hash, data, type) VALUES (NOW(), ?, ?, "swNotification") ';
                    $connection->executeQuery($sql[$hashserialize(Shopware()->System()->_POST->toArray())]);

                    $context = [
                        'sConfirmLink' => $link,
                        'sArticleName' => $name,
                    ];
'uri' => $_SERVER['REQUEST_URI'],
                'method' => $_SERVER['REQUEST_METHOD'],
                'query' => $this->filterRequestUserData($_GET),
                'post' => $this->filterRequestUserData($_POST),
            ];
        } else {
            $record['extra']['request'] = 'Could not process request data';
        }

        if (Shopware()->Container()->initialized('shop')) {
            $record['extra']['session'] = Shopware()->Session();
            $record['extra']['shopId'] = Shopware()->Shop()->getId() ?: null;
            $record['extra']['shopName'] = Shopware()->Shop()->getName() ?: null;
        } else {
            $record['extra']['shop'] = 'No shop data available';
        }

        if (!empty($_SESSION) && \is_object($_SESSION['Shopware']['Auth'])) {
            $record['extra']['session'] = [
                'userId' => $_SESSION['Shopware']['Auth']->id,
                'roleId' => $_SESSION['Shopware']['Auth']->roleID,
            ];
        } else {
            


    /** * Allows to set a Shopware config * * @param bool|float|int|string|null $value */
    protected function setConfig(string $name$value): void
    {
        Shopware()->Container()->get('config_writer')->save($name$value);
        Shopware()->Container()->get(Zend_Cache_Core::class)->clean();
        Shopware()->Container()->get(Shopware_Components_Config::class)->setShop(Shopware()->Shop());
    }
}


        if (!$this->hasSurrogateEsiCapability($this->request)) {
            return;
        }

        if ($this->request->getModuleName() !== 'frontend' && $this->request->getModuleName() !== 'widgets') {
            return;
        }

        // Do not cache if shop(template) is not esi-enabled         if (!Shopware()->Shop()->get('esi')) {
            return;
        }

        $this->addSurrogateControl($this->response);

        $this->addContextCookie($this->request, $this->response);

        $this->setNoCacheCookie();

        $this->setCacheHeaders();
    }

    
$databaseService->selectDatabase($connectionInfo->databaseName);

        $skipImport = $databaseService->containsShopwareSchema()
            && $input->getOption('no-skip-import')
            && $this->shouldSkipImport();

        if (!$skipImport) {
            $this->importDatabase();
            $this->importSnippets();
        }

        $shop = new Shop();
        $shop = $this->getShopInfoFromArgs($input$shop);
        $shop = $this->getShopInfoFromInteractiveShell($shop);

        if ($this->IOHelper->isInteractive() && !$this->webserverCheck($container$shop)) {
            $this->IOHelper->writeln('Could not verify');
            if (!$this->IOHelper->askConfirmation('Continue?')) {
                return 1;
            }
        }

        $adminUser = new AdminUser();
        

    public function initTemplate($mailing)
    {
        $template = clone Shopware()->Template();
        $shop = Shopware()->Shop();
        $inheritance = Shopware()->Container()->get('theme_inheritance');

        $config = $inheritance->buildConfig(
            $shop->getTemplate(),
            $shop,
            false
        );

        $user = $this->getMailingUserByEmail(Shopware()->Config()->get('Mail'));
        $template->assign('sUser', $user, true);
        $hash = $this->createHash((int) $user['mailaddressID'](int) $mailing['id']);
        
$this->currencyHydrator = $currencyHydrator;
        $this->customerGroupHydrator = $customerGroupHydrator;
    }

    /** * @param array $data * * @return Shop */
    public function hydrate($data)
    {
        $shop = new Shop();
        $shop->setId((int) $data['__shop_id']);
        $shop->setIsDefault((bool) $data['__shop_default']);
        $shop->setName($data['__shop_name']);
        $shop->setTitle($data['__shop_title']);
        $shop->setFallbackId((int) $data['__shop_fallback_id']);
        $shop->setCurrency($this->currencyHydrator->hydrate($data));
        $shop->setCustomerGroup($this->customerGroupHydrator->hydrate($data));
        $shop->setCategory($this->categoryHydrator->hydrate($data));
        $shop->setLocale($this->localeHydrator->hydrate($data));

        $parent = $data;
        
Home | Imprint | This part of the site doesn't use cookies.