MAJ en Thelia 2.3.4
This commit is contained in:
@@ -3,19 +3,23 @@
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Core\Event\Folder\FolderEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Files\FileModelParentInterface;
|
||||
use Thelia\Model\Base\Folder as BaseFolder;
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use Thelia\Model\Tools\PositionManagementTrait;
|
||||
use Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
class Folder extends BaseFolder implements FileModelParentInterface
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
use ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
use PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
use UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
@@ -34,25 +38,25 @@ class Folder extends BaseFolder implements FileModelParentInterface
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* count all products for current category and sub categories
|
||||
*
|
||||
* @param bool|string $contentVisibility true (default) to count only visible products, false to count only hidden
|
||||
* products, or * to count all products.
|
||||
* @return int
|
||||
*/
|
||||
public function countAllContents()
|
||||
public function countAllContents($contentVisibility = true)
|
||||
{
|
||||
$children = FolderQuery::findAllChild($this->getId());
|
||||
array_push($children, $this);
|
||||
|
||||
$contentsCount = 0;
|
||||
|
||||
foreach ($children as $child) {
|
||||
$contentsCount += ContentQuery::create()
|
||||
->filterByFolder($child)
|
||||
->count();
|
||||
$query = ContentQuery::create()->filterByFolder(new ObjectCollection($children), Criteria::IN);
|
||||
|
||||
if ($contentVisibility !== '*') {
|
||||
$query->filterByVisible($contentVisibility);
|
||||
}
|
||||
|
||||
return $contentsCount;
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +81,8 @@ class Folder extends BaseFolder implements FileModelParentInterface
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
|
||||
* @param FolderQuery $query
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user