/** * Load the root category used for a virtual category. * * @param CategoryInterface $category Virtual category. * * @return CategoryInterface */ private function getVirtualRootCategory(CategoryInterface $category) { $storeId = $this->getStoreId(); $rootCategory = $this->categoryFactory->create()->setStoreId($storeId); if ($category->getVirtualCategoryRoot() !== null && !empty($category->getVirtualCategoryRoot())) { $rootCategoryId = $category->getVirtualCategoryRoot(); $rootCategory->load($rootCategoryId); } return $rootCategory; }