Magento 2 Add Custom Tab On Customer Account Section

In this article, I will give you a simple steps to Add Custom Tab On Customer Account Section in Magento 2 Extension. Please follow bellow simple steps to custom tab In Magento 2.

Add Following files into your extension and copy that code into that files.

  1. Create customer_account.xml into Devhooks/Module/view/frontend/layout
saveCopyzoom_out_map
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="customer_account_navigation"> <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-module"> <arguments> <argument name="path" xsi:type="string">module/customer/index</argument> <argument name="label" xsi:type="string">My Module</argument> </arguments> </block> </referenceBlock> </body> </page>
  1. Create module_customer_index.xml into Devhooks/Module/view/frontend/layout
saveCopyzoom_out_map
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <update handle="customer_account"/> <body> <referenceBlock name="page.main.title"> <action method="setPageTitle"> <argument translate="true" name="title" xsi:type="string">My Module</argument> </action> </referenceBlock> <referenceContainer name="content"> <block class="Magento\Framework\View\Element\Template" name="my_module" template="Devhooks_Module::module.phtml"> </block> </referenceContainer> </body> </page>
  1. Create Index.php into Devhooks/Module/Controller/Customer
saveCopyzoom_out_map
<?php namespace Devhooks\MyModule\Controller\Customer; class Index extends \Magento\Framework\App\Action\Action { public function execute() { $this->_view->loadLayout(); $this->_view->renderLayout(); } } ?>
  1. Create module.phtml into Devhooks/Module/view/frontend/templates
saveCopyzoom_out_map
<?php // Add Your Code Here ?>

**Bingo! **

Finally, we are done, let's flush or refresh cache and test the result.

I hope this Magento article helped you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other handy commands which are not included in the list.

P.S. Do share this note with your team.




Recent Articles
Tags
Newsletter
Chrome Extension
Copyright © 2024 devhooks.in All rights reserved.
Ads OFF toggle_off
wifi_off