getCurrencies example

(string) $navigationId,
            $context,
            $salesChannel->getNavigationCategoryId(),
            $salesChannel->getNavigationCategoryDepth()
        );

        $criteria = new Criteria();
        $criteria->setTitle('header::currencies');

        $currencies = $this->currencyRoute
            ->load($event->getStoreApiRequest()$context$criteria)
            ->getCurrencies();

        $contextLanguage = $languages->get($context->getContext()->getLanguageId());
        if (!$contextLanguage) {
            throw new \RuntimeException(sprintf('Context language with id %s not found', $context->getContext()->getLanguageId()));
        }

        $page = new HeaderPagelet(
            $navigation,
            $languages,
            $currencies,
            $contextLanguage,
            
$salesChannels = $this->salesChannelRepository->search($criteria, Context::createDefaultContext())->getEntities();

        $data = [];
        foreach ($salesChannels as $salesChannel) {
            /** @var LanguageEntity $language */
            $language = $salesChannel->getLanguage();
            /** @var LanguageCollection $languages */
            $languages = $salesChannel->getLanguages();
            /** @var CurrencyEntity $currency */
            $currency = $salesChannel->getCurrency();
            /** @var CurrencyCollection $currencies */
            $currencies = $salesChannel->getCurrencies();
            /** @var SalesChannelDomainCollection $domains */
            $domains = $salesChannel->getDomains();

            $data[] = [
                $salesChannel->getId(),
                $salesChannel->getName(),
                $salesChannel->getActive() ? 'active' : 'inactive',
                $salesChannel->isMaintenance() ? 'on' : 'off',
                $language->getName(),
                $languages->map(fn (LanguageEntity $language) => $language->getName()),
                $currency->getName(),
                
$request->getHttpHost(),
                $request->getRequestUri()
            );
            $response->setRedirect($url);

            return;
        }

        // Upgrade currency         if ($request->getCookie('currency') !== null) {
            $currencyValue = $request->getCookie('currency');
            foreach ($shop->getCurrencies() as $currency) {
                if ($currencyValue == $currency->getId()
                    || $currencyValue == $currency->getCurrency()) {
                    $shop->setCurrency($currency);
                    break;
                }
            }
        }

        // Start session in frontend controllers         $session = $this->get('session');

        
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());
        }

        $shop->setBaseUrl($shop->getBaseUrl() ?: $shop->getBasePath());

        return DetachedShop::createFromShop($shop);
    }

    /** * returns the right shop depending on the request object * * @param array[] $shops * @param string $requestPath * * @return array|null */
$this->fieldHelper = $fieldHelper;
        $this->connection = $connection;
    }

    /** * @param int[] $ids * * @return Currency[] indexed by id */
    public function getList($ids)
    {
        $currencies = $this->getCurrencies($ids);
        $result = [];
        foreach ($currencies as $row) {
            $currency = $this->hydrator->hydrate($row);
            $result[$currency->getId()] = $currency;
        }

        return $result;
    }

    /** * @param int[] $ids * * @return array<array<string, mixed>> */
/** * 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]);
            }
        }
        array_unshift($languages$main);
        $this->View()->assign('languages', $languages);
    }
}
Home | Imprint | This part of the site doesn't use cookies.