Danke für die Hilfe, für die URL mit /styling funktioniert es
Leider funktioniert das nicht für die anderen Routes, aber erst seit kurzem.
Der Sprachwechsler wenn man sich direkt auf der /styling oder /en/styling Seite befindet macht:
- /fr/styling?_locale=fr-FR - Seite lädt
- /it/styling ?_locale=it-IT - Seite lädt
Wenn man jedoch den richtigen Link in der Navigation klickt, dann kommt:
- /fr/stilisme - 404
- /fr/stilo - 404
Im Controller wurde das so geregelt:
#[Route(path: '/styling', name: 'frontend.styling.default', defaults: ['_locale' => 'de'])]
// Routen für andere Sprachen mit Präfix
#[Route(path: '/fr/stylisme', name: 'frontend.styling.fr', defaults: ['_locale' => 'fr'])]
#[Route(path: '/it/stilo', name: 'frontend.styling.it', defaults: ['_locale' => 'it'])]
#[Route(path: '/en/styling', name: 'frontend.styling.en', defaults: ['_locale' => 'en'])]
In der DB seo_urls gibt es keine Einträge zu stylisme, stilo oder styling
Hat jemand eine idee?
hier noch der ganze Controller:
<?php declare(strict_types=1);
namespace SwagBasicExampleTheme\Storefront\Controller;
use Doctrine\DBAL\ArrayParameterType;
use Doctrine\DBAL\Connection;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Uuid\Uuid;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
use SwagBasicExampleTheme\Storefront\Page\Example\ExamplePageLoader;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
#[Route(defaults: ['_routeScope' => ['storefront']])]
class StylingController extends StorefrontController
{
private string $allowedSalesChannelId;
private Connection $connection;
private ExamplePageLoader $examplePageLoader;
public function __construct(
string $allowedSalesChannelId,
Connection $connection,
ExamplePageLoader $examplePageLoader
) {
$this->allowedSalesChannelId = $allowedSalesChannelId;
$this->connection = $connection;
$this->ExamplePageLoader = $examplePageLoader;
}
// Route für Deutsch (ohne Sprachpräfix)
#[Route(path: '/styling', name: 'frontend.styling.default', defaults: ['_locale' => 'de'])]
// Routen für andere Sprachen mit Präfix
#[Route(path: '/fr/stylisme', name: 'frontend.styling.fr', defaults: ['_locale' => 'fr'])]
#[Route(path: '/it/stilo', name: 'frontend.styling.it', defaults: ['_locale' => 'it'])]
#[Route(path: '/en/styling', name: 'frontend.styling.en', defaults: ['_locale' => 'en'])]
public function showStyling(Request $request, SalesChannelContext $context): Response
{
$page = $this->ExamplePageLoader->load($request, $context);
$languageId = $context->getLanguageId();
$sql = "SELECT....";
$styling = $this->connection->fetchAllAssociative($sql);
return $this->renderStorefront('@SwagBasicExampleTheme/storefront/page/styling/styling.html.twig', [
'styling' => $styling,
'page' => $page
]);
}
}
Danke und Gruss