1) To define plugin, add below code
1 2 3 4 5 6 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <type name="Magento\Theme\Block\Html\Topmenu"> <plugin name="custom_menu_item" type="Magemonkeys\AddCustomeMenu\Plugin\Topmenu" sortOrder="10" disabled="false"/> </type> </config> |
in your app/code/Magemonkeys/AddCustomeMenu/etc/frontend/di.xml file.
2) Now, Create Topmenu.php Plugin file at app/code/Magemonkeys/AddCustomeMenu/Plugin/ and paste the below code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
<?php namespace Magemonkeys\AddCustomeMenu\Plugin; use Magento\Framework\Data\Tree\NodeFactory; use Magento\Framework\UrlInterface; class Topmenu { /** * @var NodeFactory */ protected $nodeFactory; /** * @var UrlInterface */ protected $urlBuilder; /** * @param NodeFactory $nodeFactory * @param UrlInterface $urlBuilder */ public function __construct( NodeFactory $nodeFactory, UrlInterface $urlBuilder ) { $this->nodeFactory = $nodeFactory; $this->urlBuilder = $urlBuilder; } public function beforeGetHtml( \Magento\Theme\Block\Html\Topmenu $subject, $outermostClass = '', $childrenWrapClass = '', $limit = 0 ) { /** * Parent Menu */ $menuNode = $this->nodeFactory->create( [ 'data' => $this->getNodeAsArray("CMS Pages", "cms-page"), 'idField' => 'id', 'tree' => $subject->getMenu()->getTree(), ] ); /** * Add Child Menu */ $menuNode->addChild( $this->nodeFactory->create( [ 'data' => $this->getNodeAsArray("Abouts us", "abouts-us"), 'idField' => 'id', 'tree' => $subject->getMenu()->getTree(), ] ) ); $menuNode->addChild( $this->nodeFactory->create( [ 'data' => $this->getNodeAsArray("Store Location", "store-location"), 'idField' => 'id', 'tree' => $subject->getMenu()->getTree(), ] ) ); $subject->getMenu()->addChild($menuNode); } protected function getNodeAsArray($name, $id) { $url = $this->urlBuilder->getUrl($id); return [ 'name' => __($name), 'id' => $id, 'url' => $url, 'has_active' => false, 'is_active' => false, ]; } } |
3) Output :
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-628381f4ec1e1228353190/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...