Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new categoryPageId attribute #206

Merged
merged 2 commits into from
Dec 5, 2024
Merged

Conversation

sbellone
Copy link
Collaborator

@sbellone sbellone commented Dec 4, 2024

To be compatible with Category Merchandising, we are introducing a new attribute: categoryPageId

It follows the official recommendations described in this doc:
https://www.algolia.com/doc/guides/solutions/ecommerce/browse/tutorials/category-pages/#add-a-category-identifying-attribute-to-each-record

The only difference is that instead of using localized paths ("Womens", "Womens > Clothing"), we will use the categories ids:

"categoryPageId": [
    "womens"
    "womens-clothing"
]

This permits to keep the same ids across all indices, while still being human readable.

Changes

  • new categoryPageId
  • added test
  • fixed mocks setup: newarrivals category was not marked online and was missing from the existing snapshots

SFCC-401

@sbellone sbellone self-assigned this Dec 4, 2024
@sbellone sbellone requested a review from htuzel December 4, 2024 10:19
@sbellone sbellone merged commit 11f380a into develop Dec 5, 2024
5 checks passed
@sbellone sbellone deleted the feat/category-page-id branch December 5, 2024 11:28
sbellone added a commit that referenced this pull request Dec 9, 2024
Until today, we had the following list of default attributes:
`'name', 'categories', 'primary_category_id', '__primary_category', 'in_stock', 'price', 'image_groups', 'url'`

Some of them are not used by our default UI and are not following Algolia latest guidelines.
We want to replace of remove them:
- replace `categories` by the new `categoryPageId` attribute introduced in #206
- remove the `primary_category_id` attribute
- remove the undocumented `_tags` attribute: `_tags` are a built-in way
  to do filtering in Algolia, but ours only contains the product id and
  are not used

Now, the default list of attributes will be:
`'name', 'categoryPageId', '__primary_category', 'in_stock', 'price', 'image_groups', 'url'`

The former attribute definitions are kept, so if users rely on them, they can
add them to their Additional Product Attributes and their records will stay unchanged.

### Changes

- added proper attribute handler for `__primary_category`. Before, it was hardcoded
  in the `algoliaLocalizedProduct` function and computed from the `categories` attribute.
  Now it's directly computed from the SFCC product.
- updated the `defaultAttributes_v2` list
- updated tests

---
SFCC-402
htuzel pushed a commit that referenced this pull request Dec 10, 2024
Implement [Category
Pages](https://www.algolia.com/doc/guides/solutions/ecommerce/browse/tutorials/category-pages/)
using the `categoryPageId` added in #206.

This is done by adding a `filters` on the InstantSearch configuration
([doc](https://www.algolia.com/doc/guides/solutions/ecommerce/browse/tutorials/category-pages/#build-a-user-interface-with-instantsearch-js))

For categories pages, the `hierarchicalMenu` are not displayed anymore.
This is on purpose, a category page is a standalone page of a single
category.

### Changes

- Pass the `categoryId` to the `enableInstantSearch` options
  - add a `filters` on `categoryPageId` when the `categoryId` is present
- add the hierarchical menus otherwise (if we are on the search results
page)
- Remove the `breadcrumb` widget. The category title not be updated by
InstantSearch anymore, it will be updated when the user browses another
category

### How to test

- Reindex products using the latest version from `develop`, to have the
`categoryPageId` in the records
- Browse categories using the top menu

---
SFCC-407
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