updateLanguage example

/** @var LanguageEntity $language */
        foreach ($languages as $language) {
            $context = new Context(
                new SystemSource(),
                [],
                Defaults::CURRENCY,
                array_filter([$language->getId()$language->getParentId(), Defaults::LANGUAGE_SYSTEM]),
                Defaults::LIVE_VERSION
            );

            $this->updateLanguage($ids$context$all);
        }
    }

    /** * @param string[] $ids * @param string[] $all */
    private function updateLanguage(array $ids, Context $context, array $all): void
    {
        $versionId = Uuid::fromHexToBytes($context->getVersionId());
        $languageId = Uuid::fromHexToBytes($context->getLanguageId());

        
foreach ($languages as $language) {
            $languageContext = new Context(
                new SystemSource(),
                [],
                Defaults::CURRENCY,
                array_filter([$language->getId()$language->getParentId(), Defaults::LANGUAGE_SYSTEM]),
                $context->getVersionId()
            );

            $existingProducts = $products[$language->getParentId() ?? Defaults::LANGUAGE_SYSTEM] ?? [];

            $products[$language->getId()] = $this->updateLanguage($ids$languageContext$existingProducts);
        }
    }

    public function reset(): void
    {
        $this->config = [];
    }

    /** * @param array<string> $ids * @param ProductEntity[] $existingProducts * * @return ProductEntity[] */
Home | Imprint | This part of the site doesn't use cookies.