private function getNewParentTree($category)
    {
        $pathIds = array_reverse(explode(',', $category->getPathInStore()));
        $pathIds[] = $category->getId();

        /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categories */
        $categories = $this->categoryCollectionFactory->create();

        return $categories->setStore($this->storeManager->getStore())
            ->addAttributeToSelect(['name', 'is_virtual_category', 'virtual_category_root'])
            ->addFieldToFilter('entity_id', ['in' => $pathIds]);
    }
private function getNewParentTree($category)
    {
        $pathIds = array_reverse(explode(',', $category->getPathInStore()));
        $pathIds[] = $category->getId();

        /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categories */
        $categories = $this->categoryCollectionFactory->create();

        return $categories->setStore($this->storeManager->getStore())
            ->addAttributeToSelect(['name', 'is_virtual_category', 'virtual_category_root'])
            ->addFieldToFilter('entity_id', ['in' => $pathIds]);
    }
private function getNewParentTree ( $ category ) { $ pathIds = array_reverse ( explode ( ',' , $ category -> getPathInStore ( ) ) ) ; $ pathIds [ ] = $ category -> getId ( ) ; /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categories */ $ categories = $ this -> categoryCollectionFactory -> create ( ) ; return $ categories -> setStore ( $ this -> storeManager -> getStore ( ) ) -> addAttributeToSelect ( [ 'name' , 'is_virtual_category' , 'virtual_category_root' ] ) -> addFieldToFilter ( 'entity_id' , [ 'in' => $ pathIds ] ) ; }
Return parent categories of category

@param \Magento\Catalog\Model\Category $category The category

@return \Magento\Catalog\Model\ResourceModel\Category\Collection
Return parent categories of category