Extending Menus

We offer handy way to add menus when you install extension. This can be done with simple function that will do all the work of adding the menu for you to the proper place.

There is a library ‘menu_control.php’ with class AMenu. This class offers methods to control the menu for both storefront and control panel. You can add, delete menu items to access your extension. This can be done with simple call to aMenu class in install.php and in uninstall.php To install:

// add new menu item
$menu = new AMenu ( "admin_menu" );
$menu->insertMenuItem ( array (        
			"item_id"=>"your-menu",
			"item_text"=>"your_item_text_entry",
			"item_url"=>"your-item-url-or-route-to-controller",
		 	"parent_id"=>"item_id-of-parent-item",
			"sort_order"=>"number",
		 	"item_type" =>"optional-parameter-for-recognizing-items"));

To uninstall:

//delete menu item
$menu = new AMenu ( "admin_menu" );
$menu->deleteMenuItem ("sale_your-menu");

Final menu id after it is created is represented based on menu levels. It will have following structure [parent]_[parent]_....[your_menu] and as in our example it is sale_your-menu To avoid conflicts with other extensions, try to create unique menu name. Do not create generic names like products or orders.