diff --git a/src/Resources/app/administration/src/module/blog-module/component/blog-category-tree/index.js b/src/Resources/app/administration/src/module/blog-module/component/blog-category-tree/index.js index b6c5954e..e9a5697a 100755 --- a/src/Resources/app/administration/src/module/blog-module/component/blog-category-tree/index.js +++ b/src/Resources/app/administration/src/module/blog-module/component/blog-category-tree/index.js @@ -9,6 +9,7 @@ export default { return { blogCategory: null, translationContext: 'werkl-blog-category', + categories: [], }; }, @@ -28,5 +29,22 @@ export default { }, syncProducts() {}, + + async onGetTreeItems({ parentId }) { + const criteria = new Shopware.Data.Criteria(1, 500); + + // Filter by parent ID if provided (for nested categories) + // If no parentId, get root categories + if (parentId) { + criteria.addFilter(Shopware.Data.Criteria.equals('parentId', parentId)); + } + + try { + return await this.categoryRepository.search(criteria, Shopware.Context.api); + } catch (error) { + console.error('Failed to load blog categories:', error); + return null; + } + }, }, }; diff --git a/src/Resources/views/storefront/block/cms-block-blog-detail.html.twig b/src/Resources/views/storefront/block/cms-block-blog-detail.html.twig index 1e25c7af..04fe9c2a 100644 --- a/src/Resources/views/storefront/block/cms-block-blog-detail.html.twig +++ b/src/Resources/views/storefront/block/cms-block-blog-detail.html.twig @@ -1,7 +1,7 @@ {% block block_werkl_blog_detail %} {% set element = block.slots.getSlot('blogDetail') %} -