readWithFallback example


            if (!empty($object[$dispatch['id']]['dispatch_description'])) {
                $dispatch['description'] = $object[$dispatch['id']]['dispatch_description'];
            }

            $dispatch['attribute'] = Shopware()->Container()->get(DataLoader::class)
                ->load('s_premium_dispatch_attributes', $dispatch['id']);

            if (!empty($dispatch['attribute'])) {
                $languageId = $this->contextService->getShopContext()->getShop()->getId();
                $fallbackId = $this->contextService->getShopContext()->getShop()->getFallbackId();
                $translationData = $this->translationComponent->readWithFallback(
                    $languageId,
                    $fallbackId,
                    's_premium_dispatch_attributes',
                    $dispatch['id']
                );

                foreach ($translationData as $key => $attribute) {
                    $key = str_replace(CrudServiceInterface::EXT_JS_PREFIX, '', $key);
                    $dispatch['attribute'][$key] = $attribute;
                }
            }
        }
AbstractQuery::HYDRATE_ARRAY
        );

        if (Shopware()->Container()->initialized('shop')) {
            $translationComponent = Shopware()->Container()->get(Shopware_Components_Translation::class);
            $shopId = Shopware()->Shop()->getId();
            $fallbackId = 0;
            if (Shopware()->Shop()->getFallback()) {
                $fallbackId = Shopware()->Shop()->getFallback()->getId();
            }

            $translations = $translationComponent->readWithFallback($shopId$fallbackId, 'category', $id);
            if (isset($translations['description']) && (isset($result['name']) || $fields === 'name')) {
                $result['name'] = $translations['description'];
            }
        }

        if (\is_array($fields)) {
            return $result;
        }

        return $result[$fields];
    }

    
'theme' => $theme]
                );

                $theme = array_intersect_key($theme$keys);
                $defaultContext['theme'] = $theme;
            }

            $isoCode = $this->getShop()->getId();
            $translationReader = $this->getTranslationReader();

            if ($fallback = $this->getShop()->getFallback()) {
                $translation = $translationReader->readWithFallback($isoCode$fallback->getId(), 'config_mails', $mailModel->getId());
            } else {
                $translation = $translationReader->read($isoCode, 'config_mails', $mailModel->getId());
            }

            $mailModel->setTranslation($translation);
        } else {
            $defaultContext = [
                'sConfig' => $config,
            ];
        }

        

        $landingPage = $this->deviceConfiguration->getLandingPage($emotionId);
        $landingPageShops = $this->deviceConfiguration->getLandingPageShops($emotionId);

        $shopId = $context->getShop()->getId();
        $fallbackId = $context->getShop()->getFallbackId();

        if (!$landingPage || !\in_array($shopId$landingPageShops)) {
            throw new Enlight_Controller_Exception('Landing page missing, non-existent or invalid for the current shop', 404);
        }

        $translation = $this->translationComponent->readWithFallback($shopId$fallbackId, 'emotion', $emotionId);

        if (!empty($translation['name'])) {
            $landingPage['name'] = $translation['name'];
        }

        if (!empty($translation['seoTitle'])) {
            $landingPage['seo_title'] = $translation['seoTitle'];
        }

        if (!empty($translation['seoKeywords'])) {
            $landingPage['seo_keywords'] = $translation['seoKeywords'];
        }
if ($context === null) {
            $context = $this->contextService->getShopContext();
        }

        $blogArticlesQuery = $this->modelManager->getRepository(Blog::class)
            ->getListQuery($blogCategoryIds$offset$limit);
        $blogArticlesQuery->setHydrationMode(AbstractQuery::HYDRATE_ARRAY);
        $blogArticles = $blogArticlesQuery->getArrayResult();

        $routerBlogTemplate = $this->config->get('routerBlogTemplate');
        foreach ($blogArticles as $blogArticle) {
            $blogTranslation = $this->translationComponent->readWithFallback(
                $context->getShop()->getId(),
                $context->getShop()->getFallbackId(),
                'blog',
                $blogArticle['id'],
                false
            );

            if (!empty($blogTranslation)) {
                $blogArticle = array_merge($blogArticle$blogTranslation);
            }

            
return $errors;
    }

    /** * @return Form */
    protected function translateForm(Form $form, array &$fields)
    {
        $context = $this->get(ContextServiceInterface::class)->getContext();

        $translation = $this->get(Shopware_Components_Translation::class)->readWithFallback(
            $context->getShop()->getId(),
            $context->getShop()->getFallbackId(),
            'forms',
            $this->View()->getAssign('id')
        );

        if (!empty($translation)) {
            $form->fromArray($translation);
        }

        if (!empty($form->getAttribute())) {
            
$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
        );
        if ($staticPage === false) {
            return false;
        }

        

        $blogArticleId = (int) $this->Request()->getQuery('blogArticle');
        if (empty($blogArticleId)) {
            throw new Enlight_Controller_Exception('Missing necessary parameter "blogArticle"', Enlight_Controller_Exception::PROPERTY_NOT_FOUND);
        }

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

        $blogArticleQuery = $this->getRepository()->getDetailQuery($blogArticleId$shop->getId());
        $blogArticleData = $blogArticleQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY);

        $translation = $this->get(Shopware_Components_Translation::class)->readWithFallback($shop->getId()$shop->getFallback() ? $shop->getFallback()->getId() : null, 'blog', $blogArticleId);
        $blogArticleData = array_merge($blogArticleData ?? []$translation ?? []);

        // Redirect if the blog item is not available         if (empty($blogArticleData) || empty($blogArticleData['active'])) {
            throw new Enlight_Controller_Exception(sprintf('Blog article with id %d not found or inactive', $blogArticleId), 404);
        }

        // Redirect if category is not available, inactive or external         /** @var Category|null $category */
        $category = $this->getCategoryRepository()->find($blogArticleData['categoryId']);
        if ($category === null || !$category->getActive()) {
            
Home | Imprint | This part of the site doesn't use cookies.