Skip to content

Keep the product, customer and rating of a review out of the edit form - #1086

Merged
KrzysztofPajak merged 2 commits into
developfrom
fix/product-review-product-id
Nov 23, 2026
Merged

KrzysztofPajak merged 2 commits into
developfrom
fix/product-review-product-id

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Type: bugfix

Issue

ProductReviewModel.ProductId reached the edit POST from a hidden input and from the ProductId route value, and ProductReviewProfile mapped ProductId, CustomerId and Rating onto the stored review.

ProductReviewService.UpdateProductReview does not save those fields, but ProductReviewViewModelService.UpdateProductReview then recalculates the review totals for productReview.ProductId — the posted value — and the controller redirects to it. With a changed ProductId the totals of the review's own product are not refreshed (e.g. after approving it) and another product's totals are recalculated instead; with an empty one the product is not found.

Applies to Admin, Store and Vendor, which share BaseProductReviewController.

Solution

  • ProductId, CustomerId and Rating are facts of the review: [BindNever] on the model and ignored in the model → entity map, so the stored review keeps them.
  • The hidden ProductId input and the unused ProductId route value on the form are removed; the edit page still shows and links the product.
  • Approve/Disapprove selected on the list recalculated the totals of the product id posted in the reviewId:productId pair; they now use the stored review's product, so an unknown id no longer fails after the review was saved.

Breaking changes

None. The three fields were never editable in the UI.

Testing

  1. Admin → Catalog → Product reviews, open a not-approved review, tick Is approved and save: the product's approved review count goes up.
  2. Repeat on another review after changing ProductId in the form action URL / hidden field to another product id: the review's own product is updated and the other product is untouched.
  3. Same in the Store and Vendor panels for a review of a product they own.
  4. On the list, select a not-approved review and click Approve selected: its product's approved review count goes up.
  5. dotnet test src/Tests/Grand.Mapping.Tests and dotnet test src/Tests/Grand.Web.Admin.Tests --filter ProductReview pass.

The edit form posted ProductId back (hidden input and route value) and the
profile mapped ProductId, CustomerId and Rating onto the stored review.
They were not saved, but the review totals were recalculated and the
redirect built for the posted product, so a changed or empty ProductId
left the real product's totals stale or failed the save.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 18:32

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

ApproveSelected and DisapproveSelected took the product id from the
"reviewId:productId" pair the list posts, so another product's totals could
be recalculated while the review's own product kept stale ones, and an
unknown id failed after the review was saved. The product now comes from
the stored review. The edit form no longer carries a ProductId route value
nothing reads, and the mapping snapshot no longer sets fields it ignores.
@KrzysztofPajak
KrzysztofPajak merged commit 06dba7f into develop Nov 23, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/product-review-product-id branch November 25, 2026 09:09
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