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

Commit 63fca77

Browse files
didkantkostuch
authored andcommitted
Use helper getHits()
1 parent 0d7f1b7 commit 63fca77

File tree

1 file changed

+2
-3
lines changed
  • src/api/extensions/elastic-stock

1 file changed

+2
-3
lines changed

src/api/extensions/elastic-stock/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { apiStatus, getCurrentStoreView, getCurrentStoreCode } from '../../../lib/util';
2-
import { getClient as getElasticClient, adjustQuery } from '../../../lib/elastic'
2+
import { getClient as getElasticClient, adjustQuery, getHits } from '../../../lib/elastic'
33
import { Router } from 'express';
44
const bodybuilder = require('bodybuilder')
55

@@ -18,8 +18,7 @@ module.exports = ({
1818
body: bodybuilder().filter('terms', 'visibility', [2, 3, 4]).andFilter('term', 'status', 1).andFilter('terms', 'sku', skus).build()
1919
}, 'product', config)
2020
return getElasticClient(config).search(esQuery).then((products) => { // we're always trying to populate cache - when online
21-
console.log(products)
22-
return products.hits.hits.map(el => { return el._source.stock })
21+
return getHits(products).map(el => { return el._source.stock })
2322
}).catch(err => {
2423
console.error(err)
2524
})

0 commit comments

Comments
 (0)