Skip to content

feat: use category link from tweakwise#378

Open
ahuininga-orisha wants to merge 11 commits into
developfrom
feat/category-link
Open

feat: use category link from tweakwise#378
ahuininga-orisha wants to merge 11 commits into
developfrom
feat/category-link

Conversation

@ahuininga-orisha

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new "Use category URL from Tweakwise" setting under Stores → Configuration → Catalog → Tweakwise → Layered Navigation.
  • When enabled, category facet links use the <link> field from the Tweakwise navigation response instead of having Magento resolve and build the category URL at request time. This reduces server-side computation and produces more predictable URLs that are consistent with what Tweakwise has configured.
  • The feature only applies on category pages — search result pages retain the existing behaviour.
  • Falls back gracefully to the Magento-generated URL when Tweakwise does not provide a <link> value for a facet item (e.g. non-category facets always have an empty <link>).
  • Adds an explicit getLink(): string method to AttributeType to read the link field from the Tweakwise API response, making the mapping visible and type-safe instead of relying on the magic __call getter.
  • Fixes a scheme-mismatch bug in DefaultRenderer::getCategoryUrl() where a Tweakwise-provided http:// link combined with a Magento https:// base URL caused strpos to miss the match and prepend the domain a second time. The comparison is now scheme-agnostic.

How to test

Scenario 1 — Setting disabled (default behaviour unchanged)

  1. Go to Stores → Configuration → Catalog → Tweakwise → Layered Navigation.
  2. Confirm Use category URL from Tweakwise is set to No.
  3. Navigate to a category page that has a category facet (e.g. /default/women/tops-women2/).
  4. Inspect the category facet links — they should be identical to links before this change (Magento-generated URLs).

Scenario 2 — Setting enabled, Tweakwise provides a link

  1. Set Use category URL from Tweakwise to Yes and save.
  2. Flush cache.
  3. Navigate to the category page.
  4. Inspect the category facet links — they should now point directly to the category URL returned by Tweakwise in the <link> field (e.g. https://magento2.test/default/women/tops-women2/).
  5. Confirm there is no duplicated domain in any link.
  6. Click a category facet link and confirm navigation works correctly.

Scenario 3 — Setting enabled on search results page

  1. With Use category URL from Tweakwise set to Yes, perform a search that returns a category facet.
  2. Inspect the category facet links on the search results page — they should still use the Magento-generated URL, not the Tweakwise link.

Scenario 4 — http/https scheme mismatch

  1. Ensure the Tweakwise navigation response returns http:// links while Magento is configured with an https:// base URL (or vice versa).
  2. With Use category URL from Tweakwise set to Yes, navigate to the category page.
  3. Confirm category facet links contain the domain exactly once and resolve correctly.

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.

1 participant