Skip to content

fix: use route.params.term as fallback for seller page sponsored products#759

Closed
brenonovelli wants to merge 3 commits into
masterfrom
fix/seller-page-sponsored-products-term
Closed

fix: use route.params.term as fallback for seller page sponsored products#759
brenonovelli wants to merge 3 commits into
masterfrom
fix/seller-page-sponsored-products-term

Conversation

@brenonovelli

@brenonovelli brenonovelli commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This change only affects the sponsored products ads request context. Search behavior and results are unchanged.

Summary

  • SearchResultLayout now reads route.params.term via useRuntime() as a fallback when searchQuery.variables.fullText is undefined
  • Fixes sponsored products sending context: "home" on seller pages (map=sellerName, map=seller)
  • Adds spec at specs/seller-page-sponsored-products-term.md

Root cause

On seller pages, the seller name is encoded as a facet filter — not a full-text search term — so fullText is always undefined. The @vtex/ads-core SDK defaults to context: "home" when no term is provided, causing unrelated sponsored products to be returned.

The correct term is already available in route.params.term from the runtime, but was not being read.

Test plan

  • Seller page via IS redirect (map=sellerName): sponsored products request sends context: "search" + term: "ofertec"
  • Seller store page (map=seller): sponsored products request sends context: "search" + term: "shpseller382"
  • Regular full-text search: behavior unchanged — fullText takes precedence over route.params.term
  • Category/department pages: behavior unchanged — term is undefined when neither is available
  • All 124 existing tests pass

Related

ADSUP-295 — [Shopstar] Comportamento de página sem contexto em chamadas

🤖 Generated with Claude Code

@vtex-io-ci-cd

vtex-io-ci-cd Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖

Please select which version do you want to release:

  • Patch (backwards-compatible bug fixes)

  • Minor (backwards-compatible functionality)

  • Major (incompatible API changes)

And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.

  • No thanks, I would rather do it manually 😞

@brenonovelli brenonovelli marked this pull request as ready for review June 8, 2026 13:13
@brenonovelli brenonovelli requested review from a team as code owners June 8, 2026 13:13
@brenonovelli brenonovelli requested review from RodrigoTadeuF, gabpaladino and mendescamara and removed request for a team June 8, 2026 13:13
…er pages

On seller pages (map=sellerName, map=seller), fullText is undefined because
the seller name is encoded as a facet filter, not a full-text search term.
This caused useAds to send context: "home" to the ad server instead of
context: "search", returning unrelated sponsored products.

Adds route.params.term as a fallback so seller pages correctly pass the
seller name as the search term.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brenonovelli brenonovelli force-pushed the fix/seller-page-sponsored-products-term branch from 52f612d to 1402827 Compare June 8, 2026 13:44
brenonovelli and others added 2 commits June 8, 2026 11:28
…tLayout test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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