diff --git a/marketplace-service/src/main/java/com/axonivy/market/repository/impl/CustomProductRepositoryImpl.java b/marketplace-service/src/main/java/com/axonivy/market/repository/impl/CustomProductRepositoryImpl.java index 40e82370..9e21de2d 100644 --- a/marketplace-service/src/main/java/com/axonivy/market/repository/impl/CustomProductRepositoryImpl.java +++ b/marketplace-service/src/main/java/com/axonivy/market/repository/impl/CustomProductRepositoryImpl.java @@ -111,11 +111,15 @@ public List findAllProductsHaveDocument() { } private Page getResultAsPageable(Pageable pageable, Criteria criteria) { + int skip = (int) pageable.getOffset(); + int limit = pageable.getPageSize(); Aggregation aggregation = Aggregation.newAggregation( Aggregation.match(criteria), Aggregation.lookup(MongoDBConstants.PRODUCT_MARKETPLACE_COLLECTION, MongoDBConstants.ID, MongoDBConstants.ID, MongoDBConstants.MARKETPLACE_DATA), - Aggregation.sort(pageable.getSort()) + Aggregation.sort(pageable.getSort()), + Aggregation.skip(skip), + Aggregation.limit(limit) ); List entities = mongoTemplate.aggregate(aggregation, MongoDBConstants.PRODUCT_COLLECTION,