I have added CMS page link to the top menu by following the below tutorial:
http://www.amitbera.com/magento2-add-a-cms-page-link-to-menu/
Since one of the custom menu items would be Home, so it should be the first item in the menu.
I want to know that how can I make some custom menu item as the first item in the top menu using the code in the tutorial.
Update: Suppose, I have 2 custom menu items, say Home
and Contact
. I want to make Home as the first menu item and Contact as the last menu item. Is it possible with a single plugin class? or I have to write 2 different plugins to achieve this goal?
Please help.
Best Answer
There is a issue with plugin order
In default Magento already plugin define in
vendor/magento/module-catalog/etc/di.xml
And we created custom plugin in app\code{VendorName}{ModuleName}\etc\di.xml
That means core and custom plugin, both are same exist with same sort order.
If you want to display custom menu just before category menu, sort order required minimum values to core value.
Use below code for plugin and check you custom menu
I hope it will be useful for you. Let me know if not working