Skip to content

Commit d65a4b9

Browse files
ENGCOM-7978: [WIP] 1710: Dynamically identify the root categoryId for category grid #29441
- Merge Pull Request #29441 from joweecaquicla/magento2:1710-dynamically-identify-the-root-categoryid-for-category-grid - Merged commits: 1. 214ecbe 2. bb81570 3. 1fd25ea
2 parents 4b6cdb7 + 1fd25ea commit d65a4b9

File tree

1 file changed

+5
-1
lines changed
  • app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns

1 file changed

+5
-1
lines changed

app/code/Magento/MediaGalleryCatalogUi/Ui/Component/Listing/Columns/Path.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
namespace Magento\MediaGalleryCatalogUi\Ui\Component\Listing\Columns;
77

88
use Magento\Catalog\Api\CategoryRepositoryInterface;
9+
use Magento\Catalog\Model\Category;
10+
use Magento\Framework\Exception\NoSuchEntityException;
911
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1012
use Magento\Framework\View\Element\UiComponentFactory;
1113
use Magento\Ui\Component\Listing\Columns\Column;
@@ -63,13 +65,15 @@ public function prepareDataSource(array $dataSource)
6365
* Replace category path ids with category names
6466
*
6567
* @param string $pathWithIds
68+
* @return string
69+
* @throws NoSuchEntityException
6670
*/
6771
private function getCategoryPathWithNames(string $pathWithIds): string
6872
{
6973
$categoryPathWithName = '';
7074
$categoryIds = explode('/', $pathWithIds);
7175
foreach ($categoryIds as $id) {
72-
if ($id == 1) {
76+
if ($id == Category::TREE_ROOT_ID) {
7377
continue;
7478
}
7579
$categoryName = $this->categoryRepository->get($id)->getName();

0 commit comments

Comments
 (0)