Skip to content

Commit

Permalink
Fixing unused classes, and change names, test parent category ids fnc
Browse files Browse the repository at this point in the history
  • Loading branch information
ugljesaspx committed Sep 18, 2024
1 parent 9dfe7a9 commit e7bafbf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Model/Category/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,29 @@ public function resolveParentCategoryIds(CategoryInterface $category): ?array

$parentCategoryIds = null;
if ($category->getLevel() >= 1) {
$parentCategoryIds = $category->getParentIds();
$parentCategoryIds = $this->getCategoryParentIds($category['path']);

Check warning on line 136 in Model/Category/Repository.php

View workflow job for this annotation

GitHub Actions / Phan Analysis

Suspicious array access to $category of type \Magento\Catalog\Api\Data\CategoryInterface

$this->saveParentIdsToCache($category, $parentCategoryIds);
}

return $parentCategoryIds;
}

/**
* Get Parent Category IDS
*
* @param $path
* @return array
*/
private function getCategoryParentIds($path): array
{
$parentCategories = explode('/', $path);

array_pop($parentCategories);

return $parentCategories;
}

/**
* Get parent ids from cache. Return null if the cache is not available
*
Expand Down

0 comments on commit e7bafbf

Please sign in to comment.