/** * Get all categories that are not root * * @return string[] */ protected function getCategoryCodes() { if (null === $this->categoryCodes) { $this->categoryCodes = []; $categories = $this->categoryRepository->findAll(); foreach ($categories as $category) { if (null !== $category->getParent()) { $this->categoryCodes[] = $category->getCode(); } } } return $this->categoryCodes; }