Add substitution
This commit is contained in:
@@ -56,6 +56,28 @@ class Category extends BaseCategory
|
||||
return $countProduct;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root category
|
||||
* @param int $categoryId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoot($categoryId)
|
||||
{
|
||||
|
||||
$category = CategoryQuery::create()->findOneById($categoryId);
|
||||
|
||||
if(0 !== $category->getParent()) {
|
||||
$parentCategory = CategoryQuery::create()->findOneById($category->getParent());
|
||||
|
||||
if (null !== $parentCategory) {
|
||||
$categoryId = $this->getRoot($parentCategory->getId());
|
||||
}
|
||||
}
|
||||
|
||||
return $categoryId;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,28 @@ class Folder extends BaseFolder
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root folder
|
||||
* @param int $folderId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoot($folderId)
|
||||
{
|
||||
|
||||
$folder = FolderQuery::create()->findOneById($folderId);
|
||||
|
||||
if(0 !== $folder->getParent()) {
|
||||
$parentFolder = FolderQuery::create()->findOneById($folder->getParent());
|
||||
|
||||
if (null !== $parentFolder) {
|
||||
$folderId = $this->getRoot($parentFolder->getId());
|
||||
}
|
||||
}
|
||||
|
||||
return $folderId;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user