Skip to content

Commit

Permalink
@NataliaTepluhina please take a look - I’ve added the Reviews docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pkarw committed Sep 27, 2018
1 parent 9af062a commit 3afeeb0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 31 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Tutorial series on creating themes for Vue Storefront:
* [Vue Storefront + Magento 1.9](https://github.com/DivanteLtd/magento1-vsbridge)
* [Vue Storefront + with Magento checkout](https://github.com/DivanteLtd/magento2-external-checkout)
* [Vue Storefront + Pimcore](https://github.com/DivanteLtd/pimcore2vuestorefront)
* [Magento2 Product Reviews](https://github.com/DivanteLtd/vue-storefront/blob/develop/doc/Reviews.md)
* [Direct prices sync with Magento](https://github.com/DivanteLtd/vue-storefront/blob/master/doc/Direct%20Prices.md)
* [Tier prices sync with Magento](https://github.com/DivanteLtd/vue-storefront/blob/master/doc/Tier%20prices.md)
* [Shopping carts, totals and orders sync](https://github.com/DivanteLtd/vue-storefront/blob/master/doc/Totals%2C%20cart%2C%20orders%20sync%20with%20Magento.md)
Expand Down
67 changes: 36 additions & 31 deletions core/scripts/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,40 +62,45 @@ app.use('/service-worker.js', serve('dist/service-worker.js', {
}))

app.get('/invalidate', (req, res) => {
if (req.query.tag && req.query.key) { // clear cache pages for specific query tag
if (req.query.key !== config.server.invalidateCacheKey) {
console.error('Invalid cache invalidation key')
res.end('Invalid cache invalidation key')
return
}
console.log(`Clear cache request for [${req.query.tag}]`)
let tags = []
if (req.query.tag === '*') {
tags = config.server.availableCacheTags
} else {
tags = req.query.tag.split(',')
}
const subPromises = []
tags.forEach(tag => {
if (config.server.availableCacheTags.indexOf(tag) >= 0 || config.server.availableCacheTags.find(t => {
return tag.indexOf(t) === 0
})) {
subPromises.push(cache.invalidate(tag).then(() => {
console.log(`Tags invalidated successfully for [${tag}]`)
}))
if (config.server.useOutputCache) {
if (req.query.tag && req.query.key) { // clear cache pages for specific query tag
if (req.query.key !== config.server.invalidateCacheKey) {
console.error('Invalid cache invalidation key')
res.end('Invalid cache invalidation key')
return
}
console.log(`Clear cache request for [${req.query.tag}]`)
let tags = []
if (req.query.tag === '*') {
tags = config.server.availableCacheTags
} else {
console.error(`Invalid tag name ${tag}`)
tags = req.query.tag.split(',')
}
})
Promise.all(subPromises).then(r => {
res.end(`Tags invalidated successfully [${req.query.tag}]`)
}).catch(error => {
res.end(error)
console.error(error)
})
const subPromises = []
tags.forEach(tag => {
if (config.server.availableCacheTags.indexOf(tag) >= 0 || config.server.availableCacheTags.find(t => {
return tag.indexOf(t) === 0
})) {
subPromises.push(cache.invalidate(tag).then(() => {
console.log(`Tags invalidated successfully for [${tag}]`)
}))
} else {
console.error(`Invalid tag name ${tag}`)
}
})
Promise.all(subPromises).then(r => {
res.end({ message: `Tags invalidated successfully [${req.query.tag}]`, code: 0 })
}).catch(error => {
res.end(error)
console.error(error)
})
} else {
res.end({ message: 'GET Parameters key and tag are required', code: -1 })
console.error('Invalid parameters for Clear cache request')
}
} else {
res.end('GET Parameters key and tag are required')
console.error('Invalid parameters for Clear cache request')
res.end({ message: 'Cache invalidation is not required, output cache is disabled', code: 0 })
console.error('Output cache is disabled')
}
})

Expand Down
17 changes: 17 additions & 0 deletions doc/Reviews.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Product Reviews

Starting with 1.4.0 release Vue Storefront is supporting Magento2 product reviews. Unfortunatelly Magento2 REST API doesn't contain any Reviews-related endpoints, so to make it work You need to install [additional Magento2 module](https://github.com/DivanteLtd/magento2-review-api).

Installation steps (in Your Magento2 directory):

```bash
config repositories.divante vcs https://github.com/DivanteLtd/magento2-review-api.git
composer require divante/magento2-review-api:dev-master
php bin/magento setup:upgrade
```

You should be aware that Reviews are stored in the Elastic Search. To display Reviews correctly You need to update Your [mage2vuestorefront](https://github.com/DivanteLtd/mage2vuestorefront/) and run the Reviews sync:

```bash
node --harmony cli.js reviews
```

0 comments on commit 3afeeb0

Please sign in to comment.