Skip to content

feat(core): localized product URLs, breadcrumbs PDP and PLPs - #3402

Merged
hellofanny merged 3 commits into
devfrom
feat/localized-slugs-links
Jul 24, 2026
Merged

hellofanny merged 3 commits into
devfrom
feat/localized-slugs-links

Conversation

@hellofanny

@hellofanny hellofanny commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Behavioral changes

Retiring pagetype on the collection path in favor of the typed by-linkid cascade changes two observable behaviors. Neither is a schema change — no query breaks — but both are worth calling out for stores that rely on them.

1. StoreCollection.type no longer returns Cluster or SubCategory.

The old resolver passed the Catalog pageType string through verbatim, so it could return any of six values. The new resolution infers the entity type from which by-linkid endpoint answered, which yields three buckets (category / brand / collection), refined to four by fatherCategoryId:

  • Clusters now report as Collection. Clusters and curated collections are both served by collection/by-linkid, and its response carries no discriminator between them.
  • Third-level categories now report as Category. The category response exposes only fatherCategoryId, which distinguishes root from non-root but not tree depth. Recovering SubCategory would require an extra parent lookup on the PLP hot path.

Both enum values remain declared for backward compatibility and their descriptions now document that they are no longer returned. Nothing in @faststore/core selects or branches on type, so only stores that explicitly query collection { type } are affected — and they fail silently (a conditional stops matching) rather than erroring. Enum cleanup is tracked for the next major in SFS-3291.

2. Slugs that exhaust the cascade now return 404 instead of falling back to full-text search.

pagetype implicitly promoted unmatched single-segment slugs to a full-text search. The cascade returns NotFoundError when category, brand and collection all miss. This is a deliberate deferral (spec Decision 3) and can be revisited behind an explicit flag.

Summary by CodeRabbit

  • New Features
    • Added VTEX locale-specific product, category, brand, and collection lookups to power localized URLs, breadcrumbs, and SEO (including hreflang alternate links).
    • Introduced otherLocales for product and collection GraphQL responses, surfaced through new localized product page/PLP context.
  • Bug Fixes
    • Improved locale selection and fallback behavior for both localized and non-localized stores.
    • Enhanced multi-segment collection handling via by-linkid resolution, plus more reliable error “back” URLs and breadcrumb link rendering.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ec6c5e43-c57e-43eb-8493-897b7b6cff98

📥 Commits

Reviewing files that changed from the base of the PR and between 3fd89c8 and ac31738.

⛔ Files ignored due to path filters (2)
  • packages/api/src/__generated__/schema.ts is excluded by !**/__generated__/** and included by packages/**
  • packages/core/@generated/graphql.ts is excluded by !**/@generated/**, !**/@generated/** and included by packages/**
📒 Files selected for processing (2)
  • packages/api/src/platforms/vtex/resolvers/collection.ts
  • packages/api/src/platforms/vtex/typeDefs/collection.graphql
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/api/src/platforms/vtex/typeDefs/collection.graphql
  • packages/api/src/platforms/vtex/resolvers/collection.ts

Walkthrough

VTEX localization adds Catalog Dataplane product lookups, by-linkId collection resolution, localized GraphQL fields, request-scoped caching, locale-aware Core rendering, hreflang metadata, and binding redirects with persisted localized slugs.

Changes

VTEX API clients and localization

Layer / File(s) Summary
API contracts and locale plumbing
packages/api/src/platforms/vtex/clients/..., packages/api/src/platforms/vtex/utils/..., packages/api/src/platforms/vtex/index.ts
Adds typed Catalog Dataplane and by-linkId contracts, locale-aware headers, localization helpers, client wiring, request context initialization, and locale-selection tests.
By-linkId collection resolution
packages/api/src/platforms/vtex/loaders/..., packages/api/src/platforms/vtex/resolvers/collection.ts, packages/api/src/platforms/vtex/typeDefs/collection.graphql
Replaces pagetype lookup with category, brand, and collection resolution, localized slugs, breadcrumbs, facets, alternate locales, and updated collection schema behavior.
Localized product resolution
packages/api/src/platforms/vtex/resolvers/product.ts, packages/api/src/platforms/vtex/resolvers/query.ts, packages/api/src/platforms/vtex/typeDefs/product.graphql
Adds cached localized product lookups, localized slug validation, localized breadcrumbs, alternate product slugs, and classified legacy fallbacks.
API validation coverage
packages/api/test/...
Updates integration mocks and adds client, loader, collection resolver, product resolver, query resolver, and locale-selection tests.

Core locale-aware navigation

Layer / File(s) Summary
Localized product context
packages/core/src/sdk/localization/LocalizedProductContext.tsx, packages/core/src/experimental/index.ts
Adds a provider, hook, and experimental exports for localized product locale data.
Binding redirects and persistence
packages/core/src/sdk/localization/useBindingSelector.ts, packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx
Passes localized slugs into binding selection, persists PDP locale mappings in session storage, and reconstructs locale-aware redirect URLs.
Page, SEO, and breadcrumb integration
packages/core/src/pages/..., packages/core/src/components/templates/..., packages/core/src/components/ui/Breadcrumb/..., packages/core/src/components/sections/EmptyState/...
Fetches alternate locale fields, provides localized product context, generates hreflang links, preserves locale in error URLs, and renders breadcrumb items as links.
Server execution and helper tests
packages/core/src/server/index.ts, packages/core/test/sdk/localization/...
Adds per-request locale execution input and tests PDP path parsing plus localized slug persistence and recovery.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProductPage
  participant GraphQLAPI
  participant CatalogDataplane
  participant LocalizedProductProvider
  participant LocalizationButton
  ProductPage->>GraphQLAPI: request product and otherLocales
  GraphQLAPI->>CatalogDataplane: fetch localized product
  CatalogDataplane-->>GraphQLAPI: localized linkIds and categories
  GraphQLAPI-->>ProductPage: product and alternate slugs
  ProductPage->>LocalizedProductProvider: provide otherLocales
  LocalizationButton->>LocalizedProductProvider: read localized slugs
  LocalizationButton-->>ProductPage: redirect to selected locale URL
Loading

Possibly related PRs

  • vtex/faststore#3352: Shares Catalog Dataplane localization and localized product resolver paths.
  • vtex/faststore#3401: Overlaps with the VTEX by-linkId client, loader, and collection resolver changes.
  • vtex/faststore#3239: Also modifies PDP locale handling and page-level locale data loading.

Suggested labels: enhancement

Suggested reviewers: eduardoformiga, lucasfp13

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: localized URLs and breadcrumb handling for PDPs and PLPs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/localized-slugs-links

Comment @coderabbitai help to get the list of available commands.

@codesandbox-ci

codesandbox-ci Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny
hellofanny force-pushed the feat/localized-slugs-links branch from 92bc71f to ae5b6fe Compare June 19, 2026 22:55
@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@faststore/api

npm i https://pkg.pr.new/vtex/faststore/@faststore/api@ac31738

@faststore/cli

npm i https://pkg.pr.new/vtex/faststore/@faststore/cli@ac31738

@faststore/components

npm i https://pkg.pr.new/vtex/faststore/@faststore/components@ac31738

@faststore/core

npm i https://pkg.pr.new/vtex/faststore/@faststore/core@ac31738

@faststore/diagnostics

npm i https://pkg.pr.new/vtex/faststore/@faststore/diagnostics@ac31738

@faststore/lighthouse

npm i https://pkg.pr.new/vtex/faststore/@faststore/lighthouse@ac31738

@faststore/sdk

npm i https://pkg.pr.new/vtex/faststore/@faststore/sdk@ac31738

@faststore/ui

npm i https://pkg.pr.new/vtex/faststore/@faststore/ui@ac31738

commit: ac31738

@hellofanny hellofanny changed the title feat(core): localized product URLs, breadcrumbs and hreflang for PDP … feat(core): localized product URLs, breadcrumbs PDP and PLPs Jun 19, 2026
hellofanny and others added 2 commits July 23, 2026 16:53
…3352)

## Summary

Implements localized product links for FastStore stores with
localization.enabled: true (PDP only — PLP localized slugs are handled
separately).

**it-IT**
<img width="1907" height="1001" alt="image"
src="https://github.com/user-attachments/assets/b78831db-edbd-4db3-96bb-0c67b4b6c20b"
/>

**pt-BR**
<img width="1918" height="992" alt="image"
src="https://github.com/user-attachments/assets/f357c607-a37d-41e2-b13a-abf25de2629d"
/>


### Problem

FastStore stores with localization enabled had three major issues on the
PDP:
1. Localized product URLs (e.g. `/it-IT/adidas-polo-uomo-65/p`) returned
404 because the `Query.product` resolver's `startsWith` guard rejected
slugs whose prefix didn't match the Intelligent Search `linkText`
(always in the default locale).
2. Breadcrumb items were rendered as non-clickable `<span>` elements and
`BreadcrumbJsonLd` was suppressed entirely.
3. The `LocalizationSelector` had no localized product URL to navigate
to when the shopper switched locale.
4. After landing on a 404 from a locale switch, the LocalizationSelector
lost the product context and couldn't recover the correct localized URL
— and the 404 page showed the bare asPath instead of the full
locale-prefixed URL.

### Changes

@faststore/api

- New clients/catalog/ client — uses the public
catalog-dataplane/product/{id} endpoint (Accept-Language header, no
AppKey/AppToken required) to fetch localized product data (linkId,
category.fullPathUriName) per locale
- Query.product resolver: when startsWith fails and localization is
enabled, validates the slug prefix against the - - Catalog Dataplane
linkId for the current locale before rejecting
- New StoreProduct.otherLocales: [StoreProductLocale!] field — fires
Promise.all over all configured locales to build localized slug entries;
zero overhead for non-localized stores
- StoreProduct.breadcrumbList resolver: now async; uses
category.fullPathUriName from the Catalog Dataplane for localized
category URL paths and linkId for the product URL; falls back to
slugify(IS name) when no translation exists
- productTranslationsCache in GraphqlContext.storage — request-scoped
cache keyed by productId:locale shared across all three resolvers to
avoid duplicate API calls

@faststore/core

- New `LocalizedProductContext` — React context that provides
otherLocales from the PDP GraphQL response to - any component in the
tree (including global components like LocalizationButton)
- `useLocalizedProduct_unstable` exported from experimental/index.ts for
store customization
- `LocalizationButton` / `useBindingSelector`: uses otherLocales to
redirect to the correct localized product URL on locale switch; falls
back to the defaultLocale slug when no translation exists for the target
locale
- `useBindingSelector`: persists otherLocales to sessionStorage keyed by
SKU id (fs:otherLocales:{skuId}) so the locale selector can recover the
correct product URL even after the user lands on a 404 (where the page
no longer provides otherLocales)
- `Breadcrumb.tsx`: removed localization.enabled workaround — always
renders <Link> now that localized URLs are available
-`p.tsx`: restored BreadcrumbJsonLd for all locales + added hreflang
alternate tags via NextSeo.additionalLinkTags (including x-default
pointing to the root store URL)
- `EmptyState`: the fromUrl shown on the 404 page now includes the
active Next.js locale prefix (e.g. /it-IT/...) so shoppers see the full
URL they attempted to visit

### Architecture note

The Catalog Dataplane is called once per product+locale combination. For
otherLocales (all locales) and breadcrumbList (current locale only),
results are shared via productTranslationsCache. A future optimization —
replacing the Promise.all with a single "all-locales" endpoint from the
Catalog team — would be a contained 2-file change with no behavior
impact.

The sessionStorage persistence in `useBindingSelector` uses a
fs:otherLocales:{skuId} key and is intentionally session-scoped (cleared
on tab close). It is a best-effort fallback; the locale selector always
prefers live otherLocales from context when available.

## Test plan

try using `brandless` acc

- [ ] Visit a localized PDP (e.g. `/it-IT/{localized-slug}-{skuId}/p`) —
page renders correctly
eg. /adidas-mens-performance-polo-blast-blue-65/p -> switch to it-IT
locale! You will be able to see the slug localized.
- [ ] Visit a non-localized locale PDP (e.g.
`/pt-BR/{default-slug}-{skuId}/p`) — page renders correctly (fallback
path)
eg. select en-CA
- [ ] PDP breadcrumb items are clickable `<Link>` elements with
localized category URLs
- [ ] 2-level category hierarchy breadcrumb builds correct intermediate
paths
- [ ] `LocalizationSelector` navigates to the correct localized product
URL for each locale
- [ ] `LocalizationSelector` falls back to the default locale slug for
locales without a translation
- [ ] `hreflang` tags appear in `<head>` for all configured locales +
`x-default` (lists only the `availableLinkIds`)
<img width="1086" height="181" alt="Screenshot 2026-06-11 at 16 33 23"
src="https://github.com/user-attachments/assets/e1dc0ed0-3332-492b-9a1d-84a33c3a1eb4"
/>

<img width="498" height="178" alt="Screenshot 2026-06-11 at 16 37 36"
src="https://github.com/user-attachments/assets/6f52bb39-9211-4ece-8462-14e0841d6115"
/>

- [ ] `BreadcrumbJsonLd` appears in page source for all locales
- [ ] Non-localized stores (`localization.enabled: false`) — no
regression, no extra API calls
- [ ] Switch locale on a PDP → land on a 404 → LocalizationSelector
still shows/navigates to correct localized URLs for all locales
- [ ] 404 page fromUrl displays the full locale-prefixed path (e.g.
/it-IT/some-product/p)


[Spec file for more
information](vtex/faststore-dx-spec-kit#15)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

* **New Features**
* Product pages now expose `otherLocales` via a dedicated localization
context/provider.
  * Product pages generate multi-locale SEO `hreflang` alternate links.
* Added localized VTEX catalog support to fetch locale-specific
product/category details.

* **Improvements**
* Breadcrumbs now use localized category/product path segments when
available and consistently render as links.
* Locale-aware product slug validation and PDP redirects that use cached
or persisted `otherLocales`.
  * Added request-scoped caching for localized product lookups.

* **Tests**
* Expanded coverage for PDP locale parsing plus `otherLocales`
persistence/recovery behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
…ion pages (#3401)

- **Replaces `pagetype` with `by-linkid` cascade** for all stores in
`Query.collection` and `collectionLoader`. The cascade tries
`category/by-linkid` → `brand/by-linkid` → `collection/by-linkid` in
sequence; 404 advances to the next step, 5xx is a hard failure.
`pagetype` is retired on this code path.
- **Adds `StoreCollection.otherLocales`** — a new lazy GraphQL field
built from `availableLinkIds` in the `by-linkid` response, enabling the
`LocalizationSelector` to navigate to the same collection in another
locale.
- **Adds `StoreProduct.otherLocales`** and uses the Catalog Dataplane
API to resolve localized product slugs and breadcrumbs for PDP pages
(`localization.enabled` stores only).
- **Slug normalization**: all slugs are lowercased before `by-linkid`
calls, preserving parity with `pagetype`'s case-insensitive behavior
(merchants can register mixed-case `linkId` values via the Catalog
multilanguage API).
- **Canonical IS facets**: StoreCollection.meta for categories derives
the canonical (default-locale) slug from availableLinkIds[defaultLocale]
(falling back to the echoed linkId), since by-linkid echoes the
queried/localized slug. Intelligent Search still receives canonical
slugs regardless of the request locale.
- **Localized PLP fields**: Accept-Language is forwarded to by-linkid
(when localization.enabled), so collection name/title and breadcrumb
names render in the current locale.
- **Multi-segment paths**: the full accumulated path is sent to
category/by-linkid, so nested categories resolve to the correct child
unambiguously.

- New `catalog.byLinkId.{category,brand,collection}` client methods
(optional `locale` → `Accept-Language`; single-object + multi-segment
path encoding fixes)
- `collectionLoader`: replaced `pagetype` with the `by-linkid` cascade;
added `entityType` discriminator; slug normalization (`toLowerCase`)
- `StoreCollection` resolvers: `meta` (async, canonical slugs via
category tree), `breadcrumbList`, `seo`, `type`, `otherLocales` (new)
- `StoreProduct` resolvers: `otherLocales` (new), `breadcrumbList`
(localized via Catalog Dataplane)
- `Query.product`: localized slug validation via Catalog Dataplane when
`localization.enabled`
- `Query.collection`: `locale` arg validated against configured locales;
`mutateLocaleContext` + captured locale passed to loader
- GraphQL schema: `StoreCollectionLocale`, `StoreProductLocale` types;
`otherLocales` on both `StoreCollection` and `StoreProduct`
- `utils/localization.ts`: shared localization config helpers
- Search client: prefer `ctx.storage.locale` over `vtex_segment` when
`localization.enabled`
- Context factory: assign `discoveryConfig` / account / OTEL before
building clients/loaders

- `[...slug].tsx`: passes `locale` to collection query;
- `LocalizedProductContext` + `useBindingSelector`: page-agnostic locale
switching with `urlSuffix` (empty for PLP, `/p` for PDP)
- `LocalizationButton`: reads `urlSuffix` from context

- [ ] Category PLP (`/apparel`) — products load, `selectedFacets:
[{key:"category-1", value:"apparel"}]`
- [ ] Sub-category PLP (`/Computer---Software/Eletronicos`) —
multi-level breadcrumb correct
http://localhost:3000/jumper-ezbook-x3-windows-10-laptop-36/p
<img width="1918" height="980" alt="breadbrum-go-plp"
src="https://github.com/user-attachments/assets/2b62cb72-2362-4657-9697-2a28a5f78f43"
/>

- [ ] Brand PLP (`/adidas`) — `selectedFacets: [{key:"brand",
value:"adidas"}]`
- [ ] Collection PLP (`/computer---software`) — `selectedFacets:
[{key:"productclusterids", value:"..."}]`
- [ ] Localized category PLP (`/it-IT/Abbigliamento`) — resolves, no IS
500s, canonical facets sent
- [ ] Locale switch on PLP (IT → PT-BR) → navigates to
`/pt-BR/Vestuário`
- [ ] Locale switch on PLP (IT → EN) → navigates to `/apparel`
- [ ] Non-existent slug → clean 404
- [ ] PDP locale switch — `otherLocales` drives `LocalizationSelector`

- **Breadcrumb names are not localized**: `by-linkid` `name` field
always returns the default-locale value. Feedback filed with the Catalog
team to add `availableNames` or `Accept-Language` support. → Resolved:
localized via Accept-Language on by-linkid.
- **`availableLinkIds` excludes the default locale**: worked around via
category tree lookup. Feedback filed with Catalog team to include the
default locale in the map. → Resolved: beta API now includes it;
category-tree workaround removed.
- **`metaTagDescription` not yet in `by-linkid` response**: resolver
already reads `root.metaTagDescription`; will work once Catalog team
ships the field. SEO description is currently empty for collection pages
(pre-existing gap, not a regression from this PR).
- **Accent sensitivity**: by-linkid is case-insensitive but
accent-sensitive by design (/vestuário → 200, /vestuario → 404);
intentional, confirmed with Catalog team.
- PLP canonical URL currently derives from the visited URL
(router.asPath) → duplicate-content risk for casing variants.
Pre-existing issue. (Follow up
[task](https://vtex-dev.atlassian.net/browse/SFS-3281))

- Spec: `specs/localized-plp-collection-pages.md`
[PR](vtex/faststore-dx-spec-kit#18)
- Phase A (PDP): #3352

  Reference: https://vtex-dev.atlassian.net/browse/SFS-3196

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

* **New Features**
* Added locale-aware collection queries with support for category,
brand, and collection lookup by URL.
* Added localized collection links through the new `otherLocales` field.
* Added locale-specific collection and product page navigation,
including localized redirects and hreflang links.
* Improved collection breadcrumbs, metadata, facets, and category
hierarchy handling.
* **Bug Fixes**
  * Improved localized product slug validation and locale selection.
* Correctly handles missing catalog entries without masking unrelated
errors.
* **Tests**
* Expanded coverage for localized lookups, collection resolution, URL
encoding, and locale fallback behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Cursor <[email protected]>
@hellofanny
hellofanny force-pushed the feat/localized-slugs-links branch from 3620470 to 3fd89c8 Compare July 24, 2026 13:24
@hellofanny
hellofanny marked this pull request as ready for review July 24, 2026 17:01
@hellofanny
hellofanny requested a review from a team as a code owner July 24, 2026 17:01
@hellofanny
hellofanny requested review from eduardoformiga and lucasfp13 and removed request for a team July 24, 2026 17:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
packages/api/src/platforms/vtex/resolvers/collection.ts (1)

90-93: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated segment-slug construction across meta, breadcrumbList, and otherLocales.

The same slug.split('/').filter(Boolean) → cumulative-join pattern is repeated three times in this file. Extract a small getSegmentSlugs(slug: string): string[] helper to keep the three resolvers in sync.

♻️ Suggested helper
+const getSegmentSlugs = (slug: string): string[] => {
+  const segments = slug.split('/').filter(Boolean)
+  return segments.map((_, i) => segments.slice(0, i + 1).join('/'))
+}

Then replace each inline duplication with getSegmentSlugs(slug).

Also applies to: 122-129, 166-171

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/api/src/platforms/vtex/resolvers/collection.ts` around lines 90 -
93, Extract a shared getSegmentSlugs(slug: string): string[] helper for the
cumulative segment-slug construction, then replace the duplicated inline
split/filter/map logic in the meta, breadcrumbList, and otherLocales resolvers
with calls to getSegmentSlugs(slug).
packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx (1)

45-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Call useLocalizedProduct() once.

Minor readability nit: the hook is invoked twice back-to-back for two different fields.

♻️ Suggested tweak
-  const otherLocales = useLocalizedProduct()?.otherLocales ?? undefined
-  const urlSuffix = useLocalizedProduct()?.urlSuffix ?? '/p'
+  const localizedProduct = useLocalizedProduct()
+  const otherLocales = localizedProduct?.otherLocales ?? undefined
+  const urlSuffix = localizedProduct?.urlSuffix ?? '/p'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx`
around lines 45 - 46, Update the LocalizationButton component to call
useLocalizedProduct() once, store its result, and derive both otherLocales and
urlSuffix from that shared value while preserving the existing fallback
behavior.
packages/api/src/platforms/vtex/clients/commerce/types/ByLinkId.ts (1)

1-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract shared fields into a base interface.

ByLinkIdCategoryResponse, ByLinkIdBrandResponse, and ByLinkIdCollectionResponse repeat the same 5 fields (name, title, description, metaTagDescription, availableLinkIds) and duplicate the same JSDoc comment nearly verbatim. Extracting a shared base type keeps the three response contracts in sync as they evolve.

♻️ Suggested base interface
+interface ByLinkIdBaseResponse {
+  id: number
+  name: string
+  title: string | null
+  description: string | null
+  /**
+   * Optional SEO meta description. pagetype.metaTagDescription
+   * was backed by the same source as `description`; prefer `description` for
+   * parity when this field is absent.
+   */
+  metaTagDescription: string | null
+  /** Localized linkIds keyed by locale. Null when no multilanguage entries are registered. */
+  availableLinkIds: Record<string, string> | null
+}
+
-export interface ByLinkIdCategoryResponse {
-  id: number
+export interface ByLinkIdCategoryResponse extends ByLinkIdBaseResponse {
   fatherCategoryId: number | null
-  name: string
   linkId: string
-  title: string | null
-  description: string | null
-  metaTagDescription: string | null
-  availableLinkIds: Record<string, string> | null
 }

-export interface ByLinkIdBrandResponse {
-  id: number
-  name: string
+export interface ByLinkIdBrandResponse extends ByLinkIdBaseResponse {
   linkId: string
-  title: string | null
-  description: string | null
-  metaTagDescription: string | null
-  availableLinkIds: Record<string, string> | null
 }

-export interface ByLinkIdCollectionResponse {
-  id: number
-  name: string
+export interface ByLinkIdCollectionResponse extends ByLinkIdBaseResponse {
   linkId: string | null
-  title: string | null
-  description: string | null
-  metaTagDescription: string | null
-  availableLinkIds: Record<string, string> | null
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/api/src/platforms/vtex/clients/commerce/types/ByLinkId.ts` around
lines 1 - 46, Extract the repeated fields and associated JSDoc from
ByLinkIdCategoryResponse, ByLinkIdBrandResponse, and ByLinkIdCollectionResponse
into a shared base interface, then have each response interface extend it. Keep
each interface’s unique fields—such as id, fatherCategoryId, linkId, and
category-specific differences—defined locally, preserving the existing linkId
types and response contracts.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/api/src/platforms/vtex/resolvers/collection.ts`:
- Around line 67-73: Update the StoreCollectionType type resolver to return
distinct SubCategory and Cluster values where applicable, preserving Brand,
Collection, Department, and Category handling. Use the existing
collection/category discriminator symbols and recursive parent lookup needed to
identify third-level categories, and ensure curated collections and clusters are
not collapsed into Collection.

In `@packages/api/src/platforms/vtex/resolvers/query.ts`:
- Line 411: Guard URL parsing in the category mapping that computes slug from
node.url, so empty or relative values do not throw and abort the allCollections
query. Update the slug logic around new URL(node.url) to validate or safely
handle invalid URLs while preserving lowercase pathname slugs for valid absolute
URLs.

In `@packages/core/src/pages/`[slug]/p.tsx:
- Around line 98-118: Update buildHreflangLinks to select each locale’s binding
with find((b) => b.isDefault), falling back to the first binding when no default
exists, instead of always using bindings[0]. Preserve the existing URL
validation and hreflang link construction.

---

Nitpick comments:
In `@packages/api/src/platforms/vtex/clients/commerce/types/ByLinkId.ts`:
- Around line 1-46: Extract the repeated fields and associated JSDoc from
ByLinkIdCategoryResponse, ByLinkIdBrandResponse, and ByLinkIdCollectionResponse
into a shared base interface, then have each response interface extend it. Keep
each interface’s unique fields—such as id, fatherCategoryId, linkId, and
category-specific differences—defined locally, preserving the existing linkId
types and response contracts.

In `@packages/api/src/platforms/vtex/resolvers/collection.ts`:
- Around line 90-93: Extract a shared getSegmentSlugs(slug: string): string[]
helper for the cumulative segment-slug construction, then replace the duplicated
inline split/filter/map logic in the meta, breadcrumbList, and otherLocales
resolvers with calls to getSegmentSlugs(slug).

In `@packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx`:
- Around line 45-46: Update the LocalizationButton component to call
useLocalizedProduct() once, store its result, and derive both otherLocales and
urlSuffix from that shared value while preserving the existing fallback
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2535f4a9-2fcd-4981-8377-09e308ed32d6

📥 Commits

Reviewing files that changed from the base of the PR and between eb85986 and 3fd89c8.

⛔ Files ignored due to path filters (4)
  • packages/api/src/__generated__/schema.ts is excluded by !**/__generated__/** and included by packages/**
  • packages/api/test/integration/__snapshots__/queries.test.ts.snap is excluded by !**/*.snap and included by packages/**
  • packages/core/@generated/gql.ts is excluded by !**/@generated/**, !**/@generated/** and included by packages/**
  • packages/core/@generated/graphql.ts is excluded by !**/@generated/**, !**/@generated/** and included by packages/**
📒 Files selected for processing (35)
  • packages/api/src/platforms/vtex/clients/catalog/index.ts
  • packages/api/src/platforms/vtex/clients/commerce/index.ts
  • packages/api/src/platforms/vtex/clients/commerce/types/ByLinkId.ts
  • packages/api/src/platforms/vtex/clients/index.ts
  • packages/api/src/platforms/vtex/clients/search/index.ts
  • packages/api/src/platforms/vtex/index.ts
  • packages/api/src/platforms/vtex/loaders/collection.ts
  • packages/api/src/platforms/vtex/loaders/index.ts
  • packages/api/src/platforms/vtex/resolvers/collection.ts
  • packages/api/src/platforms/vtex/resolvers/product.ts
  • packages/api/src/platforms/vtex/resolvers/query.ts
  • packages/api/src/platforms/vtex/typeDefs/collection.graphql
  • packages/api/src/platforms/vtex/typeDefs/product.graphql
  • packages/api/src/platforms/vtex/utils/localization.ts
  • packages/api/test/integration/queries.test.ts
  • packages/api/test/mocks/AllCollectionsQuery.ts
  • packages/api/test/mocks/CollectionQuery.ts
  • packages/api/test/unit/platforms/vtex/clients/catalog.test.ts
  • packages/api/test/unit/platforms/vtex/clients/commerce.test.ts
  • packages/api/test/unit/platforms/vtex/clients/search.test.ts
  • packages/api/test/unit/platforms/vtex/loaders/collection.test.ts
  • packages/api/test/unit/platforms/vtex/resolvers/collection.test.ts
  • packages/api/test/unit/platforms/vtex/resolvers/product.test.ts
  • packages/api/test/unit/platforms/vtex/resolvers/query.test.ts
  • packages/core/src/components/sections/EmptyState/EmptyState.tsx
  • packages/core/src/components/templates/ProductListingPage/ProductListingPage.tsx
  • packages/core/src/components/ui/Breadcrumb/Breadcrumb.tsx
  • packages/core/src/components/ui/LocalizationButton/LocalizationButton.tsx
  • packages/core/src/experimental/index.ts
  • packages/core/src/pages/[...slug].tsx
  • packages/core/src/pages/[slug]/p.tsx
  • packages/core/src/sdk/localization/LocalizedProductContext.tsx
  • packages/core/src/sdk/localization/useBindingSelector.ts
  • packages/core/src/server/index.ts
  • packages/core/test/sdk/localization/useBindingSelector.test.tsx
💤 Files with no reviewable changes (1)
  • packages/api/test/mocks/AllCollectionsQuery.ts

Comment thread packages/core/src/pages/[slug]/p.tsx Resolved
The by-linkid migration silently narrowed StoreCollection.type: `Cluster`
and `SubCategory` are no longer reachable, because collection/by-linkid has
no discriminator between clusters and curated collections, and
category/by-linkid only exposes `fatherCategoryId` (root vs non-root, not
tree depth).

Mark both with @deprecated so introspection and generated types surface the
change instead of advertising values the resolver can never produce.
Removing them is a breaking change, tracked in SFS-3291.

Co-authored-by: Cursor <[email protected]>
@hellofanny hellofanny self-assigned this Jul 24, 2026
@hellofanny hellofanny added the enhancement New feature or request label Jul 24, 2026
@sonar-workflows

Copy link
Copy Markdown

Failed Quality Gate failed

  • 2 New Issues (is greater than 0)

Project ID: vtex_faststore_f0a862d5-9557-49f9-8d09-de40caa76622

View in SonarQube

@hellofanny
hellofanny merged commit 3c6b6ef into dev Jul 24, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants