Skip to content

feat: [SFCC-517][SEO-friedly URLs] Added stateToRoute and routeToState custom mapping#275

Merged
ede-somogyi-algolia merged 2 commits into
developfrom
feat/sfcc-516/sfcc-517-custom-mapping
Jun 10, 2026
Merged

feat: [SFCC-517][SEO-friedly URLs] Added stateToRoute and routeToState custom mapping#275
ede-somogyi-algolia merged 2 commits into
developfrom
feat/sfcc-516/sfcc-517-custom-mapping

Conversation

@ede-somogyi-algolia

@ede-somogyi-algolia ede-somogyi-algolia commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Replace InstantSearch's default routing: true (the built-in simple state mapping plus the default history router) in the SFRA instantsearch-config.js with a custom router and stateMapping. The storefront query string on category and search results pages becomes short and stable - for example ?q=jacket&brand=Apple&size=M&sort=price-asc&page=2 - instead of the index-prefixed, bracketed default.

This PR covers the URL routing (state/route mapping) only. The rel="canonical" work is handled separately.

The mapping is a sample covering the facets the cartridge ships with. Clients who add their own facet attributes extend the two functions.

Before / after

Category landing page, size L selected (master-level record model):

Before (default simple mapping + default router):

.../s/RefArch/womens/clothing/tops/?zzgk_006_dx__RefArch__products__en_US[refinementList][variants.size][0]=L

After:

.../s/RefArch/womens/clothing/tops/?size=L

Pre-existing parameters in the URL are kept intact.

@ede-somogyi-algolia ede-somogyi-algolia self-assigned this Jun 8, 2026
@ede-somogyi-algolia ede-somogyi-algolia changed the title Added stateToRoute and routeToState custom mapping feat: [SFCC-517][SEO-friedly URLs] Added stateToRoute and routeToState custom mapping Jun 8, 2026
@codacy-production

codacy-production Bot commented Jun 8, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 12 high

Alerts:

⚠ 12 issues (≤ 0 issues of at least high severity)

Results:
12 new issues

Category Results
Security 12 high

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes.

@sbellone sbellone left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, there is mostly just an issue with the overridden query string.

@sbellone sbellone left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well 👍

@ede-somogyi-algolia
ede-somogyi-algolia merged commit 85a776d into develop Jun 10, 2026
4 of 5 checks passed
@ede-somogyi-algolia
ede-somogyi-algolia deleted the feat/sfcc-516/sfcc-517-custom-mapping branch June 10, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants