refactor count loop for having better performance has mentionned in #193
This commit is contained in:
@@ -337,7 +337,7 @@ abstract class BaseLoop
|
||||
* @param $pagination
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
public function exec(&$pagination, $count = false)
|
||||
{
|
||||
if ($this instanceof PropelSearchLoopInterface) {
|
||||
$searchModelCriteria = $this->buildModelCriteria();
|
||||
@@ -361,6 +361,10 @@ abstract class BaseLoop
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) {
|
||||
return $results ? count($results) : 0;
|
||||
}
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
if (true === $this->countable) {
|
||||
|
||||
@@ -91,9 +91,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
|
||||
$dummy = null;
|
||||
|
||||
$loopResults = $loop->exec($dummy);
|
||||
|
||||
return $loopResults->valid() ? $loopResults->getCount() : 0;
|
||||
return $loop->exec($dummy, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user