feat: ui improvements, show only active products, limit max page for infinity scroll

This commit is contained in:
2025-08-09 09:49:03 +03:00
parent 7404ecb33e
commit d499d7d846
5 changed files with 17 additions and 7 deletions

View File

@@ -51,10 +51,12 @@ class ProductsService
$forMainPage = $params['forMainPage'];
$featuredProducts = $params['featuredProducts'];
$mainpageProducts = $params['mainpageProducts'];
$status = $params['status'] ?? 1;
$languageId = 1;
$categoryName = '';
$imageWidth = 300;
$imageHeight = 300;
$maxPages = $params['maxPages'] ?? 10;
if ($categoryId) {
$categoryName = $this->queryBuilder->newQuery()
@@ -82,6 +84,8 @@ class ProductsService
->where('product_description.language_id', '=', $languageId);
}
)
->where('products.status', '=', $status)
->whereRaw('products.date_available < NOW()')
->when($categoryId !== 0, function (Builder $query) use ($categoryId) {
$query->join(
db_table('product_to_category') . ' AS product_to_category',
@@ -102,7 +106,7 @@ class ProductsService
});
$total = $productsQuery->count();
$lastPage = PaginationHelper::calculateLastPage($total, $perPage);
$lastPage = min(PaginationHelper::calculateLastPage($total, $perPage), $maxPages);
$hasMore = $page + 1 <= $lastPage;
$products = $productsQuery