readBatch example

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

    public function readBatchWithFallback($language$fallback$type$key = 1, $merge = true)
    {
        $translationData = $this->readBatch($language$type$key$merge);

        // Look for a fallback and correspondent translations         if (!empty($fallback)) {
            $translationFallback = $this->readBatch($fallback$type$key$merge);

            if (!empty($translationFallback)) {
                // We need something like array_merge_recursive, but that also                 // recursively merges elements with int keys.                 foreach ($translationFallback as $translationKey => $data) {
                    if (\array_key_exists($translationKey$translationData)) {
                        $translationData[$translationKey] += $data;
                    }
Home | Imprint | This part of the site doesn't use cookies.