feat: support seo url route names of headless sales channels - #2668
Draft
Mateusz Flasiński (mateuszfl) wants to merge 1 commit into
Draft
Mateusz Flasiński (mateuszfl) wants to merge 1 commit into
Mateusz Flasiński (mateuszfl) wants to merge 1 commit into
Conversation
|
Mateusz Flasiński (@mateuszfl) is attempting to deploy a commit to the Shopware Frontends Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Since shopware/shopware#17991 (upcoming 6.7.14), headless (API type) sales channels persist their SEO URLs against the
store-api.*route family:store-api.product.detail,store-api.category.detailandstore-api.landing-page.detail. The/store-api/seo-urlendpoint returns those rows as-is, so on a headless sales channelresolvePath()hands astore-api.*route name to the page resolver,pascalCase()turns it intoStoreApiProductDetail, and the catch-all page fails withProblem resolving component: StoreApiProductDetail.This PR maps the headless route names to their storefront equivalents at the resolution boundary:
getFrontendRouteNamehelper in@shopware/helpers(store-api.product.detail→frontend.detail.pageetc.; any other route name passes through unchanged),useNavigationSearch().resolvePath()normalizes the route name of the resolvedSeoUrlentity,Everything downstream — the catch-all page resolver,
useNavigationContext, CMS page rendering, history-state navigation — keeps working unchanged for both sales channel types.This is part of finishing headless sales channel support for Composable Frontends: relates to shopware/shopware#19685 (core-side PRs: shopware/shopware#19686, shopware/shopware#19688). The end goal is dropping the "use the Storefront type" workaround from the troubleshooting guide.
Type of change
New feature (non-breaking change which adds functionality)
ToDo's
Additional context
The mapping is inert on Storefront-type channels and on Shopware < 6.7.14 (no
store-api.*rows exist there), so the change is safe to merge independently of the core PRs — opening as a draft anyway until the core side settles.Two things intentionally left out to keep this minimal, happy to follow up if wanted:
/detail/{id}) don't get a canonical 301 redirect on headless channels, because the persistedpathInfois/store-api/product/{id}and thepathInfolookup misses. The synthetic fallback still renders the page correctly.SeoUrl.routeNametype union instoreApiTypes.d.tsdoesn't include thestore-api.*values; that mirrors the core OpenAPI schema, so it likely deserves a core-side schema fix rather than a hand edit here.Open question on the mapping direction. Mapping
store-api.*ontofrontend.*is a deliberate compatibility choice, not a statement that the storefront names are the "right" ones:frontend.*is what the page-resolver component names (FrontendDetailPage& co.), the routing guide's switch examples, andgetProductRoute/getCategoryRoutehistory state are all built on, in this repo and in every downstream project. Long term — once headless sales channels are the recommended setup — it may be worth flipping the canonical vocabulary: treatstore-api.*(or better, an abstract page type likeproduct/category/landing, as already hinted at incomposables/src/types/index.ts) as the primary identifier and keepfrontend.*as the legacy alias for Storefront-type channels. That's a breaking, major-version decision that affects template component naming, so this PR only introduces the boundary normalization that would make such a flip a one-map change later. Happy to draft that follow-up if the team wants to go there.