Skip to content

Commit

Permalink
Simplify/improve product list total results and pagination object fun…
Browse files Browse the repository at this point in the history
…ctions (fix for #606)
  • Loading branch information
Mesuva committed Jan 5, 2022
1 parent 7b2ddcb commit deb53ab
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/CommunityStore/Product/ProductList.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,7 @@ public function getResult($queryRow)
protected function createPaginationObject()
{
$adapter = new DoctrineDbalAdapter($this->deliverQueryObject(), function ($query) {
$values = $query->execute()->fetchAll();
$count = count($values);

$query->resetQueryParts(['groupBy', 'orderBy', 'having', 'join', 'where', 'from'])->from('DUAL')->select($count . ' c ');
$query->resetQueryParts(['groupBy', 'orderBy'])->select('count(distinct p.pID)')->setMaxResults(1)->execute()->fetchColumn();
});
$pagination = new Pagination($this, $adapter);

Expand All @@ -408,10 +405,7 @@ public function getPaginationAdapter()
public function getTotalResults()
{
$query = $this->deliverQueryObject();
$values = $query->execute()->fetchAll();
$count = count($values);

return $query->resetQueryParts(['groupBy', 'orderBy', 'having', 'join', 'where', 'from'])->from('DUAL')->select($count)->setMaxResults(1)->execute()->fetchColumn();
return $query->resetQueryParts(['groupBy', 'orderBy'])->select('count(distinct p.pID)')->setMaxResults(1)->execute()->fetchColumn();
}

public function getResultIDs()
Expand Down

0 comments on commit deb53ab

Please sign in to comment.