/** * All viewable product groups of this group. * * @param int $numberOfProductGroups Number of product groups to display * * @return PaginatedList * * @author Sebastian Diel <*****@*****.**>, Ramon Kupper <*****@*****.**> * @since 04.01.2014 */ public function getViewableChildren($numberOfProductGroups = false) { if ($this->viewableChildren === null) { $viewableChildren = new ArrayList(); foreach ($this->Children() as $child) { if ($child->hasProductsOrChildren()) { $viewableChildren->push($child); } } if ($viewableChildren->count() > 0) { if ($numberOfProductGroups == false) { if ($this->productGroupsPerPage) { $pageLength = $this->productGroupsPerPage; } else { $pageLength = SilvercartConfig::ProductGroupsPerPage(); } } else { $pageLength = $numberOfProductGroups; } $pageStart = $this->getSqlOffsetForProductGroups($numberOfProductGroups); $viewableChildrenPage = new PaginatedList($viewableChildren, $this->getRequest()); $viewableChildrenPage->setPaginationGetVar('groupStart'); $viewableChildrenPage->setPageStart($pageStart); $viewableChildrenPage->setPageLength($pageLength); $this->viewableChildren = $viewableChildrenPage; } else { return false; } } return $this->viewableChildren; }