getFallbackId example


    public function sGetCountryTranslation($country = [])
    {
        $languageId = $this->contextService->getShopContext()->getShop()->getId();
        $fallbackId = $this->contextService->getShopContext()->getShop()->getFallbackId();

        $translationData = $this->translationComponent
            ->readBatchWithFallback($languageId$fallbackId, 'config_countries');

        if (!$country) {
            return $translationData;
        }

        if (!isset($translationData[$country['id']])) {
            return $country;
        }

        


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

            $this->data->assign('blogArticle', $blogArticle);
            $path = $this->template->fetch('string:' . $routerBlogTemplate$this->data);
            


    /** * @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())) {
            $translation = $this->get(Shopware_Components_Translation::class)->readWithFallback(
                $context->getShop()->getId(),
                


            $productProperties = $this->db->fetchAll($sql[
                'groupId' => $product['filtergroupID'],
                'shopId' => $shopContext->getShop()->getId(),
                'fallbackId' => $shopContext->getShop()->getFallbackId(),
            ]);

            foreach ($productProperties as $productProperty) {
                if (!\array_key_exists($productProperty['id']$properties)) {
                    // the key is not part of the array so add it to the end                     $properties[$productProperty['id']] = $this->extractPropertyTranslation($productProperty);
                }
            }
        }

        return $properties;
    }
$query
            ->addSelect('attributeTranslations.objectdata as __attribute_translation')
            ->leftJoin(
                'product',
                's_core_translations',
                'attributeTranslations',
                'attributeTranslations.objectkey = product.id AND attributeTranslations.objecttype = "article" AND attributeTranslations.objectlanguage = :language'
            )
        ;
        $query->setParameter(':language', $context->getShop()->getId());

        if (!$context->getShop()->getFallbackId() || $context->getShop()->getFallbackId() === $context->getShop()->getId()) {
            return;
        }

        $query
            ->addSelect('attributeTranslations_fallback.objectdata as __attribute_translation_fallback')
            ->leftJoin(
                'product',
                's_core_translations',
                'attributeTranslations_fallback',
                'attributeTranslations_fallback.objectkey = product.id AND attributeTranslations_fallback.objecttype = "article" AND attributeTranslations_fallback.objectlanguage = :languageFallback'
            )
        ;

    public function load($emotionId, ShopContextInterface $context)
    {
        $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'];
        }

        


    protected function translateItems(array $items): array
    {
        try {
            $context = $this->contextService->getShopContext()->getShop();
        } catch (Exception $e) {
            return $items;
        }

        $ids = array_column($items, 'id');
        $translations = $this->translation->readBatchWithFallback($context->getId()$context->getFallbackId()$this->type->getTableName()$ids, false);

        if (empty($translations)) {
            return $items;
        }

        foreach ($items as &$item) {
            foreach ($translations as $translation) {
                if ($translation['objectkey'] === $item['id']) {
                    $item = array_merge($item$translation['objectdata']);
                }
            }
        }

        $this->allExported = false;
    }

    /** * @param array<int> $ids * * @return array<array<string, string>> */
    private function fetchTranslations(array $ids, ShopContextInterface $shopContext): array
    {
        $data = $this->translation->readBatchWithFallback($shopContext->getShop()->getId()$shopContext->getShop()->getFallbackId(), 'blog', $ids, false);
        $translation = [];

        foreach ($data as $row) {
            $translation[$row['objectkey']] = $row['objectdata'];
        }

        return $translation;
    }
}


        $this->addTranslationWithSuffix(
            $fromPart,
            $joinCondition,
            $translationType,
            $selectName,
            $query,
            $context->getShop()->getId()
        );

        if ($context->getShop()->getFallbackId() !== $context->getShop()->getId()) {
            $this->addTranslationWithSuffix(
                $fromPart,
                $joinCondition,
                $translationType,
                $selectName,
                $query,
                $context->getShop()->getFallbackId(),
                'fallback'
            );
        }
    }

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