@@ -30,6 +30,40 @@ public function isSearchPage()
30
30
return false ;
31
31
}
32
32
33
+ /**
34
+ * @param \Magento\Catalog\Model\Category $cat
35
+ * @return string
36
+ */
37
+ protected function initCategoryParentPath (\Magento \Catalog \Model \Category $ cat ): string {
38
+ $ path = '' ;
39
+ foreach ($ cat ->getPathIds () as $ treeCategoryId ) {
40
+ if ($ path ) {
41
+ $ path .= $ this ->getConfigHelper ()->getCategorySeparator ($ this ->getStoreId ());
42
+ }
43
+ $ path .= $ this ->getCategoryHelper ()->getCategoryName ($ treeCategoryId , $ this ->getStoreId ());
44
+ }
45
+ return $ path ;
46
+ }
47
+
48
+ /**
49
+ * @param \Magento\Catalog\Model\Category $cat
50
+ * @param string $parent
51
+ * @param array $arr
52
+ * @return array
53
+ */
54
+ protected function getChildCategoryUrls (\Magento \Catalog \Model \Category $ cat , string $ parent = '' , array $ arr = array ()): array {
55
+ if (!$ parent ) {
56
+ $ parent = $ this ->initCategoryParentPath ($ cat );
57
+ }
58
+
59
+ foreach ($ cat ->getChildrenCategories () as $ child ) {
60
+ $ key = $ parent ? $ parent . $ this ->getConfigHelper ()->getCategorySeparator () . $ child ->getName () : $ child ->getName ();
61
+ $ arr [$ key ]['url ' ] = $ child ->getUrl ();
62
+ $ arr = array_merge ($ arr , $ this ->getChildCategoryUrls ($ child , $ key , $ arr ));
63
+ }
64
+ return $ arr ;
65
+ }
66
+
33
67
public function getConfiguration ()
34
68
{
35
69
$ config = $ this ->getConfigHelper ();
@@ -70,6 +104,7 @@ public function getConfiguration()
70
104
$ level = '' ;
71
105
$ categoryId = '' ;
72
106
$ parentCategoryName = '' ;
107
+ $ childCategories = [];
73
108
74
109
$ addToCartParams = $ this ->getAddToCartParams ();
75
110
@@ -88,6 +123,7 @@ public function getConfiguration()
88
123
89
124
if ($ category && $ category ->getDisplayMode () !== 'PAGE ' ) {
90
125
$ category ->getUrlInstance ()->setStore ($ this ->getStoreId ());
126
+ $ childCategories = $ this ->getChildCategoryUrls ($ category );
91
127
92
128
$ categoryId = $ category ->getId ();
93
129
@@ -236,6 +272,7 @@ public function getConfiguration()
236
272
'path ' => $ path ,
237
273
'level ' => $ level ,
238
274
'parentCategory ' => $ parentCategoryName ,
275
+ 'childCategories ' => $ childCategories
239
276
],
240
277
'showCatsNotIncludedInNavigation ' => $ config ->showCatsNotIncludedInNavigation (),
241
278
'showSuggestionsOnNoResultsPage ' => $ config ->showSuggestionsOnNoResultsPage (),
0 commit comments