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

Commit 1737a18

Browse files
authored
Merge pull request #410 from didkan/bug-fix/elastic-stock-fixes
Bug fix for elastic-stock extension
2 parents 558a241 + 92421a0 commit 1737a18

File tree

1 file changed

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

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 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

@@ -15,11 +15,10 @@ module.exports = ({
1515
index: storeView.elasticsearch.index, // current index name
1616
type: 'product',
1717
_source_includes: ['stock'],
18-
body: bodybuilder().filter('terms', 'visibility', [2, 3, 4]).andFilter('term', 'status', 1).andFilter('terms', 'sku', skus).build()
18+
body: bodybuilder().filter('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)