getTranslationComponent example

$this->checkPrivilege('read');

        /** @var Query<array<string, mixed>> $query */
        $query = $this->getListQuery($offset$limit$criteria$orderBy)->getQuery();
        $query->setHydrationMode(self::HYDRATE_ARRAY);
        $paginator = $this->getManager()->createPaginator($query);

        $translations = iterator_to_array($paginator);

        foreach ($translations as &$translation) {
            unset($translation['id']);
            $translation['data'] = $this->getTranslationComponent()->unFilterData(
                'article',
                $translation['data']
            );
        }

        return [
            'total' => $paginator->count(),
            'data' => $translations,
        ];
    }

    
return $mainData;
    }

    /** * Replaces the variant's translations with the product's. * * @param int $articleId * @param array $variants */
    protected function overrideVariantTranslations($articleId$variants)
    {
        $coreTranslations = $this->getTranslationComponent()->readBatch(null, 'article', $articleId);

        foreach ($variants as $variant) {
            $this->getTranslationComponent()->delete(null, 'variant', $variant->getId());

            foreach ($coreTranslations as &$coreTranslation) {
                unset($coreTranslation['objectdata']['metaTitle']);
                unset($coreTranslation['objectdata']['name']);
                unset($coreTranslation['objectdata']['description']);
                unset($coreTranslation['objectdata']['descriptionLong']);
                unset($coreTranslation['objectdata']['keywords']);
                $coreTranslation['objectkey'] = $variant->getId();
                
Home | Imprint | This part of the site doesn't use cookies.