Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 8ddff84

Browse files
authored
Merge pull request #341 from afirlejczyk/bugfix/set-review-status-in-api
Adding new reviews - get status from configuration.
2 parents 74ac147 + 6095581 commit 8ddff84

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ NOTE: `npm` users will still have to install the dependencies individually in th
9494

9595
## Reviews
9696
To use review feature you need to install custom module for Magento 2: [Divante ReviewApi](https://github.com/DivanteLtd/magento2-review-api)
97+
By default new reviews will be added with status "Pending".
98+
```json
99+
"review": {
100+
"defaultReviewStatus": 2
101+
},
102+
```
97103

98104
## Output Cache
99105
Vue Storefront API supports output cache for catalog operations. Cache is tagged and can by dynamically invalidated. Please find the details how to configure it [in our docs](https://docs.vuestorefront.io/guide/basics/ssr-cache.html).

config/default.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@
147147
"userGroupId": null,
148148
"useOnlyDefaultUserGroupId": false
149149
},
150+
"review": {
151+
"defaultReviewStatus": 2
152+
},
150153
"bodyLimit": "100kb",
151154
"corsHeaders": [
152155
"Link"

src/api/review.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export default ({config, db}) => {
1818
const reviewSchema = require('../models/review.schema')
1919
const validate = ajv.compile(reviewSchema)
2020

21+
req.body.review.review_status = config.review.defaultReviewStatus
22+
2123
if (!validate(req.body)) {
2224
console.dir(validate.errors);
2325
apiStatus(res, validate.errors, 500);

0 commit comments

Comments
 (0)