/** * Returns formatted root categories * * * @return array */ protected function getFormattedRootCategory($code) { if (empty($this->formattedRootCategories)) { $this->rootCategories = $this->categoryRepository->getRootNodes(); foreach ($this->rootCategories as $rootCategory) { $this->formattedRootCategories[$rootCategory->getId()] = $rootCategory->getCode(); } } return $this->formattedRootCategories[$code]; }
/** * @param ChannelManager $channelManager * @param NormalizerGuesser $normalizerGuesser */ public function __construct(ChannelManager $channelManager, NormalizerGuesser $normalizerGuesser, CategoryRepository $categoryRepository, ProductManager $productManager) { $this->channelManager = $channelManager; $this->productManager = $channelManager; $this->normalizerGuesser = $normalizerGuesser; $this->categoryRepository = $categoryRepository; $this->productManager = $productManager; if (empty($this->formatedRootCategories)) { $this->rootCategories = $this->categoryRepository->getRootNodes(); foreach ($this->rootCategories as $rootCategory) { $this->formatedRootCategories[$rootCategory->getId()] = $rootCategory->getCode(); } } }