folder and content fake

folder and content loops
This commit is contained in:
Etienne Roudeix
2013-08-02 16:18:45 +02:00
parent a117750ca8
commit fd82907209
8 changed files with 346 additions and 23 deletions

View File

@@ -4,6 +4,37 @@ namespace Thelia\Model;
use Thelia\Model\Base\Folder as BaseFolder;
class Folder extends BaseFolder {
class Folder extends BaseFolder
{
/**
* @return int number of contents for the folder
*/
public function countChild()
{
return FolderQuery::countChild($this->getId());
}
/**
*
* count all products for current category and sub categories
*
* @return int
*/
public function countAllContents()
{
$children = FolderQuery::findAllChild($this->getId());
array_push($children, $this);
$contentsCount = 0;
foreach($children as $child)
{
$contentsCount += ProductQuery::create()
->filterByCategory($child)
->count();
}
return $contentsCount;
}
}