vtex-apps / reviews-and-ratings

5 stars 20 forks source link

Import/Export Feature #21

Open duxy opened 4 years ago

duxy commented 4 years ago

Is your feature request related to a problem? Please describe. I need a way to import existing reviews when migrating stores from other platforms.

Describe the solution you'd like A nice import feature in the admin app is desirable.

Describe alternatives you've considered Don't know an easy way to import external reviews, found a way by developing an external app and use graphql, but a native solution will be the best. Additional context If Export is to much, just Import feature will be ok.

polishq commented 4 years ago

Hi @duxy , this feature is in our backlog but not currently scheduled for development.

Currently the best way to import reviews is by sending requests to VBASE (for example using Postman). You'll need to send PUTs to the first endpoint to store the actual review data, then populate the lookup table with the second endpoint:

First endpoint - Review data (stored by product ID):
https://infra.io.vtex.com/vbase/v2/{Account}/{Workspace}/buckets/vtex.reviews-and-ratings/productReviews/files/{productId}

List<Review>
Review{
Id: int (required)
CacheId: int (required)
ProductId: string (required)
Rating: int (required, number of stars from 1-5)
Title: string
Text: string
ReviewerName: string
ShopperId: string
ReviewDateTime: string
VerifiedPurchaser: boolean
Sku: string
Approved : boolean
Location : string
}

Second endpoint - Lookup table:
https://infra.io.vtex.com/vbase/v2/{Account}/{Workspace}/buckets/vtex.reviews-and-ratings/productReviews/files/productLookup

Dictionary<int, string> -- values are <review.Id, review.ProductId>

For the first endpoint, you'll want to make one PUT request per product ID, with a list of all the reviews for that product. If you make two PUTs for the same product ID, the earlier one will be overwritten. Example PUT:

[{"Id":28,"CacheId":28,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"09/26/2019 14:52:00","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":29,"CacheId":29,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"09/26/2019 14:56:55","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":30,"CacheId":30,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"10/04/2019 15:00:56","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":31,"CacheId":31,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"10/04/2019 15:01:10","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":32,"CacheId":32,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"10/04/2019 15:07:48","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":33,"CacheId":33,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"10/04/2019 15:08:43","VerifiedPurchaser":false,"Sku":null,"Approved":false},{"Id":34,"CacheId":34,"ProductId":"123","Rating":4,"Title":null,"Text":null,"ReviewerName":null,"ShopperId":"testshopper1","ReviewDateTime":"10/04/2019 15:19:26","VerifiedPurchaser":false,"Sku":null,"Approved":false}]

mroffe commented 4 years ago

Hi @polishq ! Can you help me know where to get the {Region}? Regards!

polishq commented 4 years ago

Hi @mroffe , I appreciate the question. There's actually a newer endpoint you can use that doesn't require you to know the region.

Review data: https://infra.io.vtex.com/vbase/v2/{Account}/{Workspace}/buckets/vtex.reviews-and-ratings/productReviews/files/{productId}

Lookup table: https://infra.io.vtex.com/vbase/v2/{Account}/{Workspace}/buckets/vtex.reviews-and-ratings/productReviews/files/productLookup

I've edited the instructions above to reflect this.