vuestorefront / vue-storefront-1

The open-source frontend for any eCommerce. Built with a PWA and headless approach, using a modern JS stack. We have custom integrations with Magento, commercetools, Shopware and Shopify and total coverage is just a matter of time. The API approach also allows you to merge VSF with any third-party tool like CMS, payment gateways or analytics. Newest updates: https://blog.vuestorefront.io. Always Open Source, MIT license.
https://www.vuestorefront.io
MIT License
19 stars 13 forks source link

Add ratings to reviews #272

Open haelbichalex opened 5 years ago

haelbichalex commented 5 years ago

What is the motivation for adding / enhancing this feature?

Reviews can already be imported into the vue-storefront-api and are visible in the frontend on product detail pages. Most users are probably more used to seeing 'star' reviews. In Magento this feature is implemented with ratings. You can create multiple ratings, which can be active or inactive and assigned to stores. When creating a new review you can then add ratings between 0 and 5 stars.

Ratings

At first I thought it's enough to import only the summarized rating value into vue-storefront-api, but since you can also create reviews, it might be necessary to add ratings as an entity. The rating votes should be then added to a review.

What are the acceptance criteria

Can you complete this feature request by yourself?

Which Release Cycle state this refers to? Info for developer.

Pick one option.

Additional information

haelbichalex commented 5 years ago

Hi @pkarw & @patzick :wave: I want to start working on this this week. But first I need someone to tell me about how I should structure ratings. Should ratings be a new entity? Or is it enough if a rating is attached to a given review? Then it would be not possible to add ratings to a new review though.

pkarw commented 5 years ago

I believe we should keep things simple - meaning maybe we just add a score to a review (we probably need a sum of votes + number of votes to calc the average?). It's not the best solution but keeping the individual votes in elasticsearch .. well - we can but its role is rather a cache (so it could be cleared out). We can store the votes in Redis .. but again it's a cache and could be cleared out.

To be honest - we should have an external web service (Magento extension, or just node.js app + MongoDB storage). VS should aggregate the votings from the service into ElasticSearch Review entity but shouldn't be in charge of the logic and counting the votes. This is the best solution aligned with our architecture as we're just the frontend :) Probably using a Firebase as a backend could make sense

We shouldn't have this feature in the core - it should be a separate module. Does it make sense?

haelbichalex commented 5 years ago

@pkarw Why an external web service? I would suggest using the vsbridge-indexer. There Magento can calculate the average and pass it to Elasticsearch.

pkarw commented 5 years ago

Well, I'm not exactly sure about this. Well it's the easiest way to add indexing reviews scores there but how about recordign the votes? I wouldn't like to add anything non-mageno-standard to vsbridge-indexer. Meaning - not sure if Magento already allows user to vote the raitigns? if so - cool they probably have an endpoint for voting already. If no and it's non-standard data then we need an external data storage probably. I think it would be great to have @afirlejczyk here on that - he created vsbridge-indexer and knows much more on magento than I :)

afirlejczyk commented 5 years ago

Hi @pkarw I made some fixes/changes regarding saving review with ratings in https://github.com/DivanteLtd/magento2-review-api/pull/21

I also add example for adding new review with ratings. https://github.com/DivanteLtd/magento2-review-api/blob/develop/docs/api-specs.md

https://github.com/DivanteLtd/magento2-review-api/releases/tag/1.2.0 - latest release. So please remember to update module on Magento side, to be able to show/save ratings for reviews.