fix: add product count to storefront (#719)
This commit is contained in:
@@ -16,8 +16,8 @@ describe("GET /store/products", () => {
|
||||
})
|
||||
|
||||
it("calls get product from productSerice", () => {
|
||||
expect(ProductServiceMock.list).toHaveBeenCalledTimes(1)
|
||||
expect(ProductServiceMock.list).toHaveBeenCalledWith(
|
||||
expect(ProductServiceMock.listAndCount).toHaveBeenCalledTimes(1)
|
||||
expect(ProductServiceMock.listAndCount).toHaveBeenCalledWith(
|
||||
{ status: ["published"] },
|
||||
{ relations: defaultRelations, skip: 0, take: 100 }
|
||||
)
|
||||
@@ -41,8 +41,8 @@ describe("GET /store/products", () => {
|
||||
})
|
||||
|
||||
it("calls list from productSerice", () => {
|
||||
expect(ProductServiceMock.list).toHaveBeenCalledTimes(1)
|
||||
expect(ProductServiceMock.list).toHaveBeenCalledWith(
|
||||
expect(ProductServiceMock.listAndCount).toHaveBeenCalledTimes(1)
|
||||
expect(ProductServiceMock.listAndCount).toHaveBeenCalledWith(
|
||||
{ is_giftcard: true, status: ["published"] },
|
||||
{ relations: defaultRelations, skip: 0, take: 100 }
|
||||
)
|
||||
|
||||
@@ -48,7 +48,10 @@ export default async (req, res) => {
|
||||
take: limit,
|
||||
}
|
||||
|
||||
const products = await productService.list(selector, listConfig)
|
||||
const [products, count] = await productService.listAndCount(
|
||||
selector,
|
||||
listConfig
|
||||
)
|
||||
|
||||
res.json({ products, count: products.length, offset, limit })
|
||||
res.json({ products, count, offset, limit })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user