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.
- Create
customer_account.xmlintoDevhooks/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>
- Create
module_customer_index.xmlintoDevhooks/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>
- Create
Index.phpintoDevhooks/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();
}
}
?>
- Create
module.phtmlintoDevhooks/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.
AI-Powered Recommended Articles
How to Add Link on Store Configuration Fields Comment in Magento 2
Add links in the comments of Magento 2 store configuration fields for easier navigation and support.
How to add custom link on top navigation menu in Magento 2
Learn how to add a custom link to the top navigation menu in Magento 2 for easy access to specific pages.
How to Add Dynamic Row on Store Configuration in Magento 2
Learn how to add dynamic rows to store configuration settings in Magento 2 for flexible content management.
Magento 2 Implement Declarative Schema in Custom Module.
A guide on implementing declarative schema in your custom Magento 2 modules to improve database management and scalability.
How to set customer data in httpContext and retrieve it in Magento 2.
Learn how to set and retrieve customer data using HttpContext in Magento 2 for personalized customer experiences.
How to Call CMS Block Using Layout XML in Magento 2
Learn how to call CMS blocks using layout XML in Magento 2 to manage content display.