Skip to content

feat: feed the customer rating facet of the product listings - #30

Merged
anoziere merged 6 commits into
thelia-modules:mainfrom
pierrebaguet:feat/473-rating-facet-source
Oct 21, 2026
Merged

anoziere merged 6 commits into
thelia-modules:mainfrom
pierrebaguet:feat/473-rating-facet-source

Conversation

@pierrebaguet

Copy link
Copy Markdown
Contributor

Why

The core adds a customer rating facet to the product listings: 4, 3 and 2 stars and up. The core holds no review, so it reads them through Thelia\Domain\Catalog\Product\ProductRatingSourceInterface, which a review module implements. Without an implementation the facet does not show.

What

  • Comment\Front\RatingFacetSource implements the interface. It compares the stored average of the accepted comments (meta_data, COMMENT_RATING), the figure the product card shows and the best-rated order sorts on, cast the same way, so the facet and the order never disagree.
  • The facet counts on five stars while a shop can rate on another scale (comment_max_rating). The threshold is brought to that scale: 4 stars and up on a shop rating out of ten means an average of 8 or more.
  • RatingMetaStorageInterface::elementIdsRatedAtLeast(), implemented by RatingMetaRepository and by the in-memory double of the tests.
  • On a core without the interface (3.2), configureServices() leaves the class out, so the module still installs there.

Companion pull request

The core pull request that adds the facet and the interface (thelia/thelia).

Tests

Tests/Unit/Front/RatingFacetSourceTest.php: threshold on the stored average, scale of the shop, products asked about, ratings of other elements ignored. The scale test was seen red with the conversion removed. Module suite: 115 tests.

The SQL of elementIdsRatedAtLeast() is not covered by the module tests, which run without a database. It was checked on the demo database: five reviews accepted in the back office, the facet then offered 4 stars and up (2 products), 3 and up (3) and 2 and up (4), and 4 and up kept the two expected products.

@anoziere
anoziere force-pushed the feat/473-rating-facet-source branch from ca17a60 to 19c123e Compare October 18, 2026 17:34
@anoziere

Copy link
Copy Markdown
Contributor

Review done, nothing to fix in the code. I pushed one commit that raises the requirement to Thelia 3.3 (thelia/core: ^3.3 and <thelia>3.3.0</thelia>): ProductRatingSourceInterface only exists from 3.3.0, so a 3.2 shop must not pick this version. The PHPStan check on published Thelia stays red until 3.3.0 is out; the PR gets merged right after that release.

@anoziere
anoziere merged commit 43ed1be into thelia-modules:main Oct 21, 2026
5 checks passed
@anoziere

Copy link
Copy Markdown
Contributor

Correction of my earlier note: no need to wait for 3.3.0. Comment::configureServices() only wires RatingFacetSource when the core has ProductRatingSourceInterface, so the module keeps working on 3.2. I reverted the 3.3 requirement and added a PHPStan baseline that leaves that class out of the analysis on the published core. Merged.

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