Fixed root-category relation with home-category

Co-authored-by: Eugene Polozov <eugene@retailcrm.es>
This commit is contained in:
opheugene 2020-11-12 13:57:54 +03:00 committed by GitHub
parent 41ce30b143
commit fb0c45bfd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,7 @@ class RetailcrmCatalog
$categoriesIds[] = $categoryId;
$categories[] = array(
'id' => $categoryId,
'parentId' => self::getParentCategoryId($category['id_parent']),
'parentId' => self::getParentCategoryId($categoryId, $category['id_parent']),
'name' => $category['name'],
'picture' => $picture ? $protocol . $picture : ''
);
@ -336,16 +336,21 @@ class RetailcrmCatalog
/**
* Returns active parent category
*
* @param int $categoryId
* @param int $parentId
*
* @return null
*/
private static function getParentCategoryId($parentId)
private static function getParentCategoryId($categoryId, $parentId)
{
$home = Configuration::get('PS_HOME_CATEGORY');
if (empty($parentId)) {
return $home;
return null;
}
if ($categoryId == $home) {
return null;
}
if ($parentId == $home) {