updateSeoUrls example


        $context = Context::createDefaultContext();

        $fk = Uuid::randomHex();
        $seoUrlUpdates = [
            [
                'foreignKey' => $fk,
                'pathInfo' => 'normal/path',
                'seoPathInfo' => 'fancy-path',
            ],
        ];
        $this->seoUrlPersister->updateSeoUrls($context, 'foo.route', array_column($seoUrlUpdates, 'foreignKey')$seoUrlUpdates$this->salesChannel);
        $seoUrls = $this->seoUrlRepository->search(new Criteria(), Context::createDefaultContext())->getEntities();
        static::assertCount(1, $seoUrls);

        $this->seoUrlPersister->updateSeoUrls($context, 'foo.route', array_column($seoUrlUpdates, 'foreignKey')$seoUrlUpdates$this->salesChannel);
        $seoUrls = $this->seoUrlRepository->search(new Criteria(), Context::createDefaultContext())->getEntities();
        static::assertCount(1, $seoUrls);

        $seoUrlUpdates = [
            [
                'foreignKey' => $fk,
                'pathInfo' => 'normal/path',
                

        }

        foreach ($buildUrls as $languageId => $config) {
            $context = new Context(
                $context->getSource(),
                $context->getRuleIds(),
                $context->getCurrencyId(),
                [$languageId]
            );

            $this->persister->updateSeoUrls(
                $context,
                self::ROUTE_NAME,
                array_column($config['urls'], 'foreignKey'),
                $config['urls'],
                $config['salesChannel']
            );
        }
    }

    private function getTranslatedTitle(?CustomerGroupTranslationCollection $translations, LanguageEntity $language): string
    {
        
continue;
            }

            $chain = $languageChains[$config['languageId']];
            $languageContext = new Context(new SystemSource()[], Defaults::CURRENCY, $chain);
            $languageContext->setConsiderInheritance(true);

            // generate new seo urls             $urls = $this->seoUrlGenerator->generate($ids$template$route$languageContext$salesChannel);

            // persist seo urls to storage             $this->seoUrlPersister->updateSeoUrls($languageContext$routeName$ids$urls$salesChannel);
        }
    }

    /** * Loads the SEO url templates for the given $routeName for all combinations of languages and sales channels * * @param non-empty-string $routeName * * @return list<array{salesChannelId: string, languageId: string, template: string}> */
    private function loadUrlTemplate(string $routeName): array
    {
if ($salesChannel === null) {
            throw SeoException::salesChannelNotFound($salesChannelId);
        }

        if ($salesChannel->getTypeId() === Defaults::SALES_CHANNEL_TYPE_API) {
            if (Feature::isActive('v6.6.0.0')) {
                return new Response('', Response::HTTP_NO_CONTENT);
            }
        }

        $this->seoUrlPersister->updateSeoUrls(
            $context,
            $seoUrlData['routeName'],
            [$seoUrlData['foreignKey']],
            [$seoUrlData],
            $salesChannel
        );

        return new Response('', Response::HTTP_NO_CONTENT);
    }

    #[Route(path: '/api/_action/seo-url/create-custom-url', name: 'api.seo-url.create', methods: ['POST'])]
Home | Imprint | This part of the site doesn't use cookies.