Liferay 7.2 - How to add Navigation Menus programmatically?

Fabio Carvalho, modified 6 Years ago. Junior Member Posts: 81 Join Date: 6/25/19 Recent Posts
Hi,

I have been adding groups and layouts with the GroupLocalServiceUtil and LayoutLocalServiceUtil classes respectively. I was wondering if there is some way to add Navigation Menus programmatically with some Util class like the previous examples.

How can I add a Navigation Menu programmatically?
thumbnail
Mohammed Yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi ,
You can try below Utilities    
SiteNavigationMenuLocalServiceUtil
SiteNavigationMenuItemLocalServiceUtil
Fabio Carvalho, modified 6 Years ago. Junior Member Posts: 81 Join Date: 6/25/19 Recent Posts
Hi Mohammed,

Thanks a lot for the answer. This looks indeed the solution, but I can't find those classes anywhere.  Using any of those classes on my portlet result on a "cannot be resolved as a type". Are those classes from a certain package that I need to import?
thumbnail
Mohammed Yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
You can use this gradle dependency compile group: 'com.liferay', name: 'com.liferay.site.navigation.api', version: 'as per your target'
Fabio Carvalho, modified 6 Years ago. Junior Member Posts: 81 Join Date: 6/25/19 Recent Posts
That's it! Thank you very much!