Skip to main content

📝 Product-Specific Reviews

This guide focuses on managing and displaying reviews for individual products using the Alphabite Reviews Plugin.


✅ Prerequisites

  • A Medusa backend with the Reviews plugin installed and configured.
  • Existing reviews associated with products.

🔨 Step-by-Step Implementation

1. List Reviews for a Product

To get all reviews for a specific product, use the listProductReviews endpoint.

const { reviews, count } = await sdk.alphabite.reviews.listProductReviews({
product_id: "prod_...",
limit: 10,
offset: 0,
// Optional filters:
// my_reviews_only: true,
// verified_purchase_only: true,
// rating: 4,
// sort: "created_at", // or "rating"
// order: "desc", // or "asc"
});

console.log(`Found ${count} reviews for product:`, reviews);

2. Get Aggregate Counts for a Product

To retrieve the average rating and distribution of ratings for a product, use the aggregateCounts endpoint.

const { average, counts, total_count } = await sdk.alphabite.reviews.aggregateCounts({
product_id: "prod_...",
// Optional filter:
// verified_purchase_only: true,
});

console.log(`Average rating: ${average}`);
console.log(`Total reviews: ${total_count}`);
console.log("Rating distribution:", counts);
API Reference

Learn more about our Medusa SDK Wrapper Alphabite Medusa SDK Wrapper 🔗

You can view the full endpoint documentation for:


📝 Notes

  • The listProductReviews endpoint allows filtering by my_reviews_only, verified_purchase_only, rating, and sorting by created_at or rating.
  • The aggregateCounts endpoint provides a quick summary of review data for a product, useful for displaying star ratings and review counts on product listings.